jquery 可选择插件选择第一级子级,而不是子级的子级
<ol id="selectable">
<li class="ui-widget-content">
<div><input type="checkbox" /></div>
<div>Item1</div>
<div>Khanput</div>
<div>1/2/3</div>
<div>15:03:16</div>
<div>--------</div>
<div>23m</div>
<div>Chakwal</div>
</li>
</ol>
我只想选择“li”元素而不是“div”,但它会选择所有元素。 我尝试了一些方法,但没有成功。
<ol id="selectable">
<li class="ui-widget-content">
<div><input type="checkbox" /></div>
<div>Item1</div>
<div>Khanput</div>
<div>1/2/3</div>
<div>15:03:16</div>
<div>--------</div>
<div>23m</div>
<div>Chakwal</div>
</li>
</ol>
I just want to select the 'li' element not the 'div' but it selects them all.
I have tried a few things but they did not work out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使
元素可选择,那么当单击
但就 jQuery UI 而言,实际上只有
被“选中”。您可以看到这一点,因为您的
ui-selected
类;相反,其中的内容被赋予 ui-selectee 类。If you make the
<li>
element selectable it stands to reason that the content inside it would also become 'selected' when the<li>
is clicked.As far as jQuery UI is concerned though, only the
<li>
is actually 'selected'. You can see this as your<li>
will be given a class ofui-selected
when it's selected; the content within, conversely, is given theui-selectee
class.您可以添加此自定义插件,
然后您的代码将是
我在这里找到的解决方案
如何防止 jQuery UI Selectable 插件中的多重选择
You can add this custom plugin
then your code will be
I found the solution here
How to prevent multiple selection in jQuery UI Selectable plugin