javascript - want to show and hide div with jquery -


i new jquery, , don't understand 100%. want div containing text or image, , when click on it, show div.

html:

 <div class="mytrigger">click here</div>  <div class="mycontent">show when clicking on above</div> 

jquery:

<script>  $( ".mytrigger" ).click(function() {    $( ".mycontent" ).toggle( "slow", function() {    });  }); </script> 

so, when click on "mytrigger", must show "mycontent.

just leave function inside toggle-call away:

$(function() {     $( ".mytrigger" ).click(function() {         $(".mycontent").toggle("slow");     }); }); 

see: http://jsfiddle.net/a8np4/3/

edit: wrapped in dom-ready-call


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -