jQuery的'点击'不是射击时图标按钮 [英] Jquery 'click' not firing when icon is on button
本文介绍了jQuery的'点击'不是射击时图标按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用引导
和的jQuery
。我有三个按键,分别在它的图标。当我绑定一个点击
-event一个按钮,它的工作原理,当我点击按钮(边),而不是当我点击它的中间,上图标...
I use Bootstrap
and jQuery
. I have three buttons, each with an icon in it. When I bind an click
-event to a button, it works when I click on the button (on the edge), but not when I click on the middle of it, on the icon...
我的code是这样的:
My code looks like this:
<div class="btn-group">
<button class="btn btn_change_status" id="134" rel="tooltip" data-original-title="Tooltip">
<i class="icon-eye-open"></i>
</button>
...
</div>
...
$('button.btn_change_status').on('click', function(e) {
alert(e.target.id);
return false;
});
我怎么能由绑定的所有包裹着我的元素 btn_change_status
来的点击事件?
推荐答案
您需要一个不同的语法,按的文档:
You need a different syntax, as per the documentation:
$('body').on('click', 'button.btn_change_status', function(e) {
alert(e.target.id);
return false;
});
这篇关于jQuery的'点击'不是射击时图标按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文