Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Posts
    419
    Thanks
    18
    Thanked 2 Times in 2 Posts

    onclick opacity change

    I have a svg file with several rollovers that change opacity when moused over, using css. But if the user clicks one of these rollovers when it becomes visible, I want that to stay opacity:1, until one of the other rollovers is clicked. using :active didn't work. Not sure how to do this in conjunction with the rollovers.

    Note: the onclick currently in there, is to pass a variable to the page for use elsewhere.


    Here's what I've got:

    Code:
    <svg xmlns="http://www.w3.org/2000/svg" version="1.1"
          width="550" height="250"  viewBox="0 0 650 350">
          
          <script type='text/ecmascript'><![CDATA[
          function ToggleOpacity(targetId) {
    
                SVGDocument.getElementById(targetId).setAttributeNS(null, 'class', 'active');
             }
        
          
          ]]></script>
          
          
          <style type="text/css" media="screen">
         .overlay1 { opacity:0;}
         .overlay1:active { opacity:.9; }
    	.overlay1:hover { opacity:.9; 
    	}
    	
    	.overlay_active { opacity:1;}
    
    	.active { opacity:1;}
    
    	</style>
    <g class="overlay1"
    onclick="top.showit('option33');ToggleOpacity('overlay1');">
    
          	<path d="M144,129 205,129 205,174 144,174" style="fill:#97aa2b;" />
          	<text x="166" y="159" font-family="arial" font-size="19" fill="white" 
          	> 05 </text>
     </g>
    
    
    
    <g class="overlay1"
    onclick="top.showit('option33')">
    
          	<path d="M144,175 205,175 205,219 144,219" style="fill:#97aa2b;" />
          	<text x="166" y="203" font-family="arial" font-size="19" fill="white" 
          	> 06 </text>
     </g>
    </svg>

  • #2
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,461
    Thanks
    1
    Thanked 23 Times in 21 Posts
    Why SVGDocument instead of document?
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #3
    New Coder
    Join Date
    Apr 2013
    Posts
    21
    Thanks
    0
    Thanked 1 Time in 1 Post
    I think because it's an svg file.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •