Translate

Thursday 6 June 2013

Toggle in Simple Javascript

                                      
         Download:coding

index.php:

<div class="jtr">
   
    <div id="opt"><a href="#" onclick="toggle_visibility('foo');"><img src="HH.png" width="23px" height="23px" style="border:0 solid #F00; width:23px; height:23px; margin-left:160px;"/></a>
        
        <div id="foo"><span class="panel"><a href="">My Blog</a>
        <a href="">My Rating</a>
        <a href="">Your Ads</a>
        <a href="">My Images</a>
        <a href="">My Videos</a>
        <a href="">Edit Profile</a>
        <a href=""> Change Password</a>
        <a href="">Logout</a></span></div>
      

    </div></div>

script:
<script type="text/javascript">

    function toggle_visibility(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'none';
       else
          e.style.display = 'block';
    }
</script>

No comments:

Post a Comment