带有复选框的 jQueryUI 手风琴 [英] jQueryUI accordion with checkboxes

查看:17
本文介绍了带有复选框的 jQueryUI 手风琴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的每个手风琴标题中放置一个复选框,以指示是否应该禁用某些内容.该复选框显示正常,但是,由于整个手风琴标题链接到 标签,因此无法点击.将复选框放在 <a> 标签之外会使复选框出现在标题下方,这不是我想要的,而且仍然无法点击.

<h3><a href="#">Text <span id="id">更多文本<input type="checkbox"/></span></a></h3><div>内容等</div>

您可以使用 stopPropagation() 解决这个问题

jsfiddle 示例

类似的东西

$('#accordion input[type="checkbox"]').click(function(e) {e.stopPropagation();});

I'm trying to put a checkbox in each of my accordion headings to indicate whether something should be disabled or not. The checkbox shows up fine, however, its not clickable as the whole accordion header is linked to the <a> tag. Putting the checkbox outside the <a> tag makes the checkbox appear underneath the heading, which is not what I want, and it still isn't clickable either.

<div id="accordion">
    <h3><a href="#">Text <span id="id">More text<input type="checkbox"/></span></a></h3>
    <div>content etc</div>
</div>

解决方案

You can use stopPropagation() to fix this

example jsfiddle

something like

$('#accordion input[type="checkbox"]').click(function(e) {
    e.stopPropagation();
});

这篇关于带有复选框的 jQueryUI 手风琴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆