jQuery UI可选禁用 [英] jQuery UI Selectable disable
本文介绍了jQuery UI可选禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用jQuery UI Selectable可用于有序列表中的列表项,但我只想禁用该ol中的一个列表项,是他们的任何方式吗?
这是我的代码
Im using jQuery UI Selectable for list items in Ordered list, But i just want to disable only one list item from that ol, is their any way to do that? here is my code
<ol id="selectable">
<li>enable & selectable</li>
<li>enable & selectable</li>
<li>enable & selectable</li>
<li>disable & not selctable</li>
</ol>
<script type="text/javascript">
$( "#selectable" ).selectable();
</script>
推荐答案
可选小部件提供 过滤器
可用于包含子项的选项匹配元素:
The Selectable widget provides a filter
option that can be used to include children of the matched element:
$("#selectable").selectable({
filter: ".something" //Give the elements to be selectable a class
});
您的HTML看起来像这样:
Your HTML would then look something like this:
<ol id="selectable">
<li class="something">enable & selectable</li>
<li class="something">enable & selectable</li>
<li class="something">enable & selectable</li>
<li>disable & not selctable</li>
</ol>
这是工作示例。
如果要排除的 li
始终是最后一个,就像你的例子中一样,你可以避免为每个 li
元素添加一个类,并使用:not
和:最后
选择器:
If the li
you want to exclude is always the last one, like in your example, you could avoid adding a class to each of the li
elements and use the :not
and :last
selectors:
$("#selectable").selectable({
filter: "li:not(:last)"
});
这篇关于jQuery UI可选禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文