簡體   English   中英

jQuery-查找具有某些屬性的第一個上一個節點

[英]jquery - find first previous node with certain properties

無論父/子關系等如何,如何找到具有特定屬性的最接近$(this)節點的節點,例如class =“ field”?

$(this).closest(".field");

文檔: http : //api.jquery.com/closest/

這應該可以解決問題(假設.field是它的父級):

$(this).closest(".field");
$(this).parents(".field:first")

這並不是我最接近的意思,我最終這樣做是這樣的:

$(this).parent('.jdpicker_w').next('.spacer').children()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM