静态页面 jquery事件生效
jQuery 动态生成后,事件失效
看代码
//动态生成html
$(".a").html("<input type='text' class='b' />");
//绑定事件
$(".b").on("click", function(){
alert("动态html");
});
//事件失效
//修改成
$("body").on("click", ".b", function(){
alert("动态html");
});
//事件生效。