jQueryUI手风琴与复选框 [英] jQueryUI accordion with checkboxes

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

问题描述

我想在每个手风琴标题中加上一个复选框,以指示是否应该禁用某项功能。该复选框显示得很好,但是它的不可点击,因为整个手风琴标题链接到< a> 标签。将复选框放在< a> 标记之外使复选框出现在标题下方,这不是我想要的,它仍然是不可点击的。

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>


推荐答案

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

You can use stopPropagation() to fix this

示例jsfiddle

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

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

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