Annie The Cross Annie The Cross - 1 year ago 83
HTML Question

Click function on class

how can I improve my script if I want to on click on h3 show p - but I have more of these elements and they open all on click. Is it necessary to give all h3 id?

$('.question h3').click(function(){
$('.question p').toggle();

Answer Source

Can you try like this:

 $('.question h3').click(function(){

via $.next() we are targeting next DOM element.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download