1

I have a div with this content

<h3>title list1</h3>
<ul><li>element1</li>
<li>element2</li>`</ul>

repeated many times

i want that clicking on the h3 the ul right after it is toggled using jquery. i've tried with:

.first()

But it toggles only the first ul not the first after the clicked h3, how can i do?

1 Answer 1

3

If the <ul> elements always occur immediately after the <h3> elements, you can use next():

$("h3").click(function() {
    $(this).next().toggle();
});
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.