![](/img/trans.png)
[英]How to find whether the class attribute is present or not in the input element using Jquery
[英]Jquery - How to find an element using class and attribute
我試圖找出找到我元素的最有效方法。 繼我的smy結構:
<div class="a" customattrib="2">
為了找到這個元素,我可以這樣做:
$("div.a [customattrib='2']")
這似乎不起作用,還有另一種方法嗎?
沒有課程,我可以獲得價值,但我認為這對我的結構來說不夠高效:
$("div [customattrib='2']")
刪除空格:
$("div.a[customattrib='2']")
通過放入空格,你將它變成一個后代選擇器,它找到匹配[customattrib='2']
所有元素,並且位於匹配div.a
的元素內 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.