How do I select a sibling element using jQuery?
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", "");
Use jQuery .siblings()
to select the matching sibling.
$(this).siblings('.bidbutton');
$(this).siblings(".bidbutton")
$("h2").siblings().css({"color": "blue"});