<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>

我需要构建选择器来查找包含id = X的元素,并通过.draggable('disable');禁用此项目

有人这样想:

data-shortid=X所在的位置找到类y并使其成为
$("ul li").find(".ShortID").attr("data-shortid="+X+).draggable('disable');

答:
$("span.ShortID[data-shortid="+ShortId+"]").parents("li:first").draggable("disable");

最佳答案

您需要禁用li而不是span,因此需要找到父级:

$("span.ShortID[data-shortid=1007]").parents("li").draggable("disable");

10-07 21:50