I want to toggle closest class '.wdm_bundled_item'
on '.mainClass_
n'
What I had tried :
jQuery('.mainClass_1').on('click', function(e){
e.preventDefault();
$(this).nextUntil('.codeByBilal').toggle();
});
Working fine, just the issue is it's toggling the last tr
too when I click on '.mainClass_4'
Any suggestion please? with nextUntil
or something else.
Thanks
Use filter()
to filter out the elements with the desired class.
jQuery('.mainClass_1').on('click', function(e){
e.preventDefault();
$(this).nextUntil('.codeByBilal').filter('.wdm_bundled_item').toggle();
});