aid

Monday, 18 August 2014

how to add toggle link in javascript

how to add toggle link in javascript

here is example for adding toggle link of content which you want to show or hide.
below listed code is the complete example of the.
<script type="text/javascript">
function toggle(){
 
  var contentId = document.getElementById("id");

  contentId.style.display == "block" ? contentId.style.display = "none" :
contentId.style.display = "block";
}
        </script>
       
<a href="javascript:void(0);" onclick="toggle()">show</a>
<div id="collapse1">

some content goes here

</div>

No comments:

Post a Comment