<ul>
<li id="RadListBox1_i2" class="rlbItem ui-draggable">
<div class="ui-draggable ui-state-default" data-shortid="1007">
<em>ProductId: </em>
<span>110-01-070-10</span>
<br>
<em>ShortID: </em>
<span class="ShortID" data-shortid="1007">1007</span>
<br>
<em>Product Name: </em>
<span>Clearly Retro Style Colour Name Necklace</span>
<br>
<em>
</div>
</span>
</li>
<li id="RadListBox1_i3" class="rlbItem ui-draggable">
<li id="RadListBox1_i4" class="rlbItem ui-draggable">
</ul>
我需要.draggable('disable');
如何使選擇器,找到類和數據-ID = X
建立選擇器,找到包含ID = X元素和禁用此項目有些人認爲這樣的:
發現類y其中data-shortid=X
並使其
$("ul li").find(".ShortID").attr("data-shortid="+X+).draggable('disable');
答:
$("span.ShortID[data-shortid="+ShortId+"]").parents("li:first").draggable("disable");
的可能重複的[jQuery的如何找到基於數據屬性值的元素?](http://stackoverflow.com/questions/4191386/jquery-how-to-find-an-element-based-on -a-data-attribute-value) –
我需要找到基於1:Class和2:data-attribute的元素AND 3:使其可拖動(禁用)?播種不重複! –
您不知道如何按屬性選擇元素,這就是其他問題所涵蓋的內容。此外,按類別選擇僅意味着組合兩個選擇器。看[存在多少個選擇器](http://api.jquery.com/category/selectors/),我們不能對每個可能的組合有任何疑問。我們必須期望人們至少知道CSS選擇器的基礎知識。 –