I am trying to create a switching effect using the + and - fields to show and hide the div. And an example http://theodin.co.uk/tools/tutorials/jqueryTutorial/index.html
This is a script I am using
$(function(){
$('.block').hide();
$('#show').toggle(function(){
$('.block').show();
$(this).attr("src","images/minus.jpg" );
},function(){
$('.block').hide();
$(this).attr("src", "images/plus.jpg" );
});
});
HTML
<div id="show"> Open <img id="show" src="images/plus.jpg"/> </div>
<div class="block">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
</div>
It works fine with one div, but I have several, and when I click one, they all show. Is there a way to switch them individually using the code I have?
source
share