0

Im trying to toggle the function but its not working. i don't where im wrong

Fiddle

Tried Code

$('.toggledropdown').click(function(e){
 // $('.showdropdowninv',this).toggle('slow');
 $('.showdropdowninv').toggle('slow');
});

I need to toggle particular clicked ul but its not working . Im using this function its not working

something like this

$('.showdropdowninv',this).toggle('slow');
2
  • What do you mean by "toggle the function"? Commented Sep 18, 2016 at 11:35
  • can u check my fiddle toglle both works at the same time. I need to both work seprately Commented Sep 18, 2016 at 11:37

1 Answer 1

2

To toggle the display of just the items associated with the clicked anchor, use jQuery's DOM navigation methods to go up to the closest parent div, then down to the .showdropdowninv item(s) within that div only:

$('.toggledropdown').click(function(e){
  $(this).closest('div').find('.showdropdowninv').toggle('slow');
});

Updated version of your fiddle: http://jsfiddle.net/V4X4t/243/

(Obviously the closest parent element might not be a div in all cases, but it is for the html in your fiddle. You could also select the parent by class, e.g., for your html you could use .closest('.element-dragging').)

(Note also that you could use a similar technique to implement the "Select all" checkboxes for each group.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.