[英]You can't click an element after you replace it
I have element with click event. 我有点击事件元素。 On click I replace this element by another, but element class is same (event by class(jQuery)).
单击时,我将这个元素替换为另一个,但是元素类是相同的(按类的事件(jQuery))。 But click doesn't work 2 time.
但是点击无法正常工作2次。
Bind the event on the parent node: 在父节点上绑定事件:
<div id="the_parent">
<button>Replace me!</button>
</div>
$('#the_parent').on('click', 'button', function (ev) {
// TODO: handle appropriately
});
See: http://api.jquery.com/on/#on-events-selector-data-handler : 请参阅: http : //api.jquery.com/on/#on-events-selector-data-handler :
.on( events [, selector ] [, data ], handler )
selector
选择器
Type: String
类型:字符串
A selector string to filter the descendants of the selected elements that trigger the event.
一个选择器字符串,用于过滤触发事件的所选元素的后代。 If the selector is
null
or omitted, the event is always triggered when it reaches the selected element.如果选择器为
null
或省略,则事件在到达所选元素时始终被触发。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.