如何使用jquery在页面加载后捕获动态插入的DOM元素上的事件(.click())?
这是怎么回事!
$("#test").click(function(){
$(this).css("background","#CCCCCC");
});
$("#clickme").click(function(){
$("body").append("<div id="test">My background isn't changeable!</div>");
});
http://jsfiddle.net/d87ckf1k/3/
$(document).on("click","#test",function(){
$(this).css("background","#CCCCCC");
});
http://jsfiddle.net/d87ckf1k/4/