Bootstrap:不需要的手风琴行为 [英] Bootstrap: Unwanted accordion behaviour
本文介绍了Bootstrap:不需要的手风琴行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码可以正常工作.当用户单击复选框时,我不想扩大或折叠一行.我该如何阻止?(我插入了jquery.我想知道是否可以使用它来解决问题?)
The following code works fine....except.... I don't want to expand or callapse a row when the user clicks a checkbox. How can I block this? (I have jquery plugged in. I'm wondering if I can use this to solve the problem?)
<table class="table table-hover">
<thead>
<td>
<h5>Select All:</h5>
</td>
<td>
<h5><input type="checkbox" id="checkAll"></h5>
</td>
</thead>
<tbody>
<tr>
<td colspan="2"> <input type="submit" , value="Replace Selected"> </td>
</tr>
<tr class="accordion-toggle" data-toggle="collapse" data-target="#tgt1">
<td> Heading </td>
<td><input type="checkbox" value="92340332" name="c1"></td>
</tr>
<tr>
<td colspan="2">
<div id="tgt1" class="collapse">content content</div>
</td>
</tr>
<tr class="accordion-toggle" data-toggle="collapse" data-target="#tgt2">
<td>Heading</td>
<td><input type="checkbox" value="146735230" name="c2"></td>
</tr>
<tr>
<td colspan="2">
<div id="tgt2" class="collapse">content content</div>
</td>
</tr>
</tbody>
</table>
推荐答案
您需要在复选框
中使用 e.stopPropagation();
来防止./p>
You'll need to use e.stopPropagation();
to your checkbox
to prevent.
$("myElement").on('click', function (e) { e.preventDefault(); })
或
$('input').click(function(e) {
e.stopPropagation(); // prevents event e from going to parent
});
这篇关于Bootstrap:不需要的手风琴行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文