我div
使用jQueryon
方法动态附加了元素,但是当我将侦听器附加到动态更新的元素时,它不起作用了吗?
的HTML
<input class="123" type="button" value="button" />
<input class="123" type="button" value="button" />
<div id="footer"></div>
jQuery的
$(document).ready(function () {
$('.onlineUsers').on('click', function () {
$('#footer').append("<div class=\"chatboxes\"> <div class=\"close\"><a href=\"#\">x</a></div> </div>");
});
$('a').on('click', function () {
alert("hello");
});
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句