I am having a problem which i am not able to understand at the moment. I have a script in jsp which creates dynamic <p> and <div> tags. Each <p> tag has class ‘parent’ and each div class has class ‘child’. Now what I want to achieve is, when a user clicks on a particular <p> tag then the <div> which is just under that <p> should appear. But when I click on <p> tag now..its opening all the divs..of other <p> tags too. Kindly help me with this.
thanks
Thank you guys…I made few changes in the code..and its working fine now.
$(document).ready(function(){
$(".child").hide();
$(".parent").bind('click',function(){
$(this).next('.child').toggle("slow");
});
});
In jQuery
The
.next()method tells jQuery to select the “immediately following sibling”, which in your case would be the div.