Selecting parent s next sibling s children in jQuery

0 votes

This is an illustration of a part of my DOM:

enter image description here

I want to trigger an effect on div with class des (which is in an odd div) on click event of div with class but (which is in the previous even div)

How can I select des from but?

Aug 4, 2022 in Web Development by gaurav
• 23,260 points
488 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Trivially, if this is the clicked .but element:

$(this).parent().next().children('.des')

This does assume that there are no other elements in the way, i.e. that the .even and .odd elements are immediate siblings, and that .but and .des are immediately children of their respective .even and .odd ancestors.

Less efficiently, but guaranteed to work with any arbitrary number of additional (non-matching) elements in the tree would be:

$(this).closest('.even').nextAll('.odd').first().find('.des')
answered Aug 4, 2022 by anonymous

edited Mar 5

Related Questions In Web Development

0 votes
1 answer

Get checkbox value in jQuery

To get the value of the Value ...READ MORE

answered Jun 23, 2022 in Web Development by rajatha
• 7,680 points
789 views
0 votes
1 answer

Get checkbox value in jQuery

if you have set a class or id for it, you ...READ MORE

answered Jun 23, 2022 in Web Development by rajatha
• 7,680 points
848 views
0 votes
1 answer

JQuery Ajax Post results in 500 Internal Server Erro

The 500 Internal Server Error is a ...READ MORE

answered Jun 23, 2022 in Web Development by rajatha
• 7,680 points
32,737 views
0 votes
1 answer

explode string in jquery

Use the JavaScript split() method If you want ...READ MORE

answered Jun 23, 2022 in Web Development by rajatha
• 7,680 points
3,199 views
0 votes
1 answer

how to use substr() function in jquery?

To get substring of a string in ...READ MORE

answered Jun 27, 2022 in Web Development by rajatha
• 7,680 points
1,381 views
0 votes
1 answer

How to loop through array in jQuery?

Generic loop: var i; for (i = 0; i ...READ MORE

answered Jun 28, 2022 in Web Development by rajatha
• 7,680 points
2,373 views
0 votes
1 answer

What is jQuery?

Hey, jQuery is a fast and concise JavaScript ...READ MORE

answered Feb 14, 2020 in JQuery by kartik
• 37,520 points
1,581 views
0 votes
1 answer

Uncaught TypeError: Cannot read property 'msie' of undefined - jQuery tools

Hello, Use the following script tag in your ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,840 points
16,620 views
0 votes
1 answer

Uncaught Error: Bootstrap's JavaScript requires jQuery

Hello @kartik, You have provided wrong order for ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,840 points
23,894 views
0 votes
1 answer

How to make Bootstrap popover Appear/Disappear on hover instead of click?

Hello @kartik, Set the trigger option of the popover to hover instead ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,840 points
3,592 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP