How do I select a sibling element using jQuery

0 votes

Can you help me with this jQuery selector?

$(".auctiondiv .auctiondivleftcontainer .countdown").each(function () {
    var newValue = parseInt($(this).text(), 10) - 1;
    $(this).text(newValue);

    if (newValue == 0) {
        $(this).parent().fadeOut();
        chat.verify($(this).parent().parent().attr('id'));
    }
});

Basically, I want to select the element with .bidbutton class that belongs in the same parent as the .countdown in the each loop:

<div class="auctiondivleftcontainer">
    <p class="countdown">0</p>
    <button class="btn primary bidbutton">Lance</button>                            
</div>  

And then apply this to that button:

$(button here).addClass("disabled");
$(button here).attr("disabled", "");

Jun 7, 2022 in JQuery by Edureka
• 13,690 points
2,378 views

1 answer to this question.

0 votes

jQuery siblings() Method

The siblings() method returns all sibling elements of the selected element. Sibling elements are elements that share the same parent. The DOM tree: This method traverse forward and backwards along siblings of DOM elements.

answered Jun 7, 2022 by Edureka
• 13,690 points

Related Questions In JQuery

0 votes
1 answer

How do I iterate through children elements of a div using jQuery?

Hello @kartik, Use children() and each(), you can optionally pass a ...READ MORE

answered Oct 5, 2020 in JQuery by Niroj
• 82,880 points
5,392 views
0 votes
1 answer

How do I add options to a DropDownList using jQuery?

Without using any extra plugins, var myOptions = ...READ MORE

answered Jun 21, 2022 in JQuery by rajatha
• 7,680 points
464 views
0 votes
1 answer

How do I pre-populate a jQuery Datepicker textbox with today's date?

Hello @kartik, You must FIRST call datepicker() > then use ...READ MORE

answered May 29, 2020 in JQuery by Niroj
• 82,880 points
12,126 views
0 votes
1 answer

How can I select an element with multiple classes in jQuery?

Hello @kartik, If you want to match only ...READ MORE

answered Sep 10, 2020 in JQuery by Niroj
• 82,880 points
3,383 views
0 votes
1 answer

jQuery $(this) selector function and limitations

this isn't a jQuery "thing", but a basic JavaScript ...READ MORE

answered Jun 23, 2022 in Web Development by rajatha
• 7,680 points
603 views
0 votes
0 answers

jquery attribute selector escape doublequote

I want to select a html element ...READ MORE

Aug 11, 2022 in Web Development by gaurav
• 23,260 points
552 views
0 votes
1 answer

How to use jquery with asp.net ajax?

If you weren't aware, Microsoft is planning ...READ MORE

answered Oct 15, 2018 in IoT (Internet of Things) by Annie97
• 2,160 points
710 views
0 votes
1 answer

Is 'sparkline' a method?

I suggest you to check 2 things That jquery.sparkline.js is actually ...READ MORE

answered Nov 9, 2018 in Apache Spark by Frankie
• 9,830 points
1,195 views
0 votes
1 answer

How do I select a sibling element using jQuery?

Use jQuery . siblings() to select the matching ...READ MORE

answered Jun 6, 2022 in JQuery by Edureka
• 13,690 points
452 views
0 votes
1 answer

How can I create a "Please Wait, Loading..." animation using jQuery?

Use the ajaxStart() and ajaxStop() Method While working ...READ MORE

answered Jun 7, 2022 in JQuery by Edureka
• 13,690 points
1,737 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