Reputation: 1759
I have this jquery code to toggle a submenu on click.
jQuery(document).ready(function($){
$(".widget .menu-item-has-children").click(function () {
$(".widget .menu-item-has-children > .sub-menu").toggle();
});
});
But this display all .sub-menu, not only clicked link children. How can i put "only do this to children" with jquery?
Upvotes: 0
Views: 33
Reputation: 14225
jQuery(document).ready(function($){
$('.widget .menu-item-has-children').click(function () {
// `this` refers to the current `.widget .menu-item-has-children`
$(this).children('.sub-menu').toggle();
});
});
Upvotes: 2