Target an <ul>l element with class="menus" excluding the others, only one at a time

Asked

Viewed 20 times

2

jQuery(document).ready(function() {
  $('.heading-list').bind('click',function(){
    $('.list').children().css({ 'display': 'block' });

  })


   $('.heading-list').bind('dblclick',function(){
    $('.list').children().css({ 'display': 'none' });      

   })  
});

I want that when clicking on the title, only the Child list of that title and the other lists are not called tbm to explain better: https://jsfiddle.net/FernandoSouza/67z3y1nr/#

  • Can you explain the question further?

1 answer

1


You can use $(this).next('.list') to find the right element.

jQuery(document).ready(function() {
  $('.heading-list').on('click', function() {
    $(this).next('.list').children().toggle();
  });
});

Example: jsFiddle

  • 1

    It looks like it works better. It perfectly solves the problem. Thanks bro!!! :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.