logo

  • Hỏi Đáp
  • Kiến Thức
  • Sức Khỏe
  • Tử Vi
  • Công Nghệ
No Result
View All Result
logo
No Result
View All Result
Trang chủ how to select sibling elements in jquery

How To Select Sibling Elements In Jquery

by Admin _ December 06, 2022

$(".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 lớn select the element with .bidbutton class that belongs in the same parent as the .countdown in the each loop:


And then apply this khổng lồ that button:

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

*

*

Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first)
*

*

*

you can use $(this).siblings(".bidbutton").addClass("disabled");$(this).siblings(".bidbutton").attr("disabled","");
$("selector").nextAll(); $("selector").prev(); you can also find an element using Jquery selector

$("h2").siblings("table").find("tr");
If you want to select a specific sibling:

var $sibling = $(this).siblings(".bidbutton");where "index" is the index of the specific sibling within the parent container.

Bạn đang xem: How to select sibling elements in jquery


Since $(this) refers to .countdown you can use $(this).next() or $(this).next("button") more specifically.

Xem thêm:


also if you need khổng lồ select a sibling with a name rather than the class, you could use the following

var $sibling = $(this).siblings("input");
If I understood that correctly you"re already in a loop (each) so you would always want to lớn select that one sibling button inside each loop runthrough?Since siblings() returns an array, this would be the way lớn go:

$(this).siblings(".bidbutton")<0>You can apply both things you wanted in a single line doing this:

$(this).siblings(".bidbutton")<0>.addClass("disabled").attr("disabled", "");
Thanks for contributing an answer to lớn Stack Overflow!

Please be sure to lớn answer the question. Provide details and share your research!

But avoid …

Asking for help, clarification, or responding lớn other answers.Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.


Post Your Answer Discard

By clicking “Post Your Answer”, you agree khổng lồ our terms of service, privacy policy và cookie policy


Site design / hình ảnh © 2022 Stack Exchange Inc; user contributions licensed under CC BY-SA. Rev2022.12.5.43077


Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Share Tweet Linkedin Pinterest
Previous Post

Demo jquery input number format

Next Post

Jquery add elements

CÙNG CHUYÊN MỤC

jquery file upload (hayageek plugin) error case with json from php

Jquery file upload (hayageek plugin) error case with json from php

28/04/2021
search/filter table rows based on input

Search/filter table rows based on input

28/04/2021
jquery multiple select dropdown

Jquery multiple select dropdown

28/04/2021
khai báo biến trong jquery

Khai báo biến trong jquery

28/04/2021
sự kiện click() và dblclick() trong jquery

Sự kiện click() và dblclick() trong jquery

03/01/2023
how to select sibling elements in jquery

How to select sibling elements in jquery

06/12/2022
jquery access input hidden value

Jquery access input hidden value

27/11/2022
upload nhiều file đồng thời sử dụng tính năng kéo thả với jquery multiple file uploader

Upload nhiều file đồng thời sử dụng tính năng kéo thả với jquery multiple file uploader

23/11/2022

Newsletter

The most important automotive news and events of the day

We won't spam you. Pinky swear.

Chuyên Mục

  • Hỏi Đáp
  • Kiến Thức
  • Sức Khỏe
  • Tử Vi
  • Công Nghệ

News Post

  • Nnn là gì trên facebook

About

Chúng tôi tạo ra trang web nhằm mục đích mang lại kiến thức bổ ích cho cộng đồng, các bài viết được sưu tầm từ nhiều nguồn trên internet giúp mang lại kiến thức khách quan dành cho bạn

©2023 darkedeneurope.com - Website WordPress vì mục đích cộng đồng

Liên Hệ - Giới Thiệu - Nội Quy - Bảo Mật

No Result
View All Result
  • Trang chủ
  • Chuyên mục
    • Hỏi Đáp
    • Kiến Thức
    • Sức Khỏe
    • Tử Vi
    • Công Nghệ
  • Lưu trữ
  • Liên hệ

© 2023 darkedeneurope.com - Website WordPress vì mục đích cộng đồng.