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

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

collision detection - C++ library for mesh to mesh intersection: what is available? -

python - Django-easy-pdf: xhtml2pdf reporting reportlab 2.2+ is required, but 3.0 installed -