html动态生成后,之前定义的jqeury方法不起作用
html动态添加内容是很常见的,遇到了好几次,然后有去找了一下知道了解决办法,但是一段时间没用有点模糊,特意做个记录。
解决办法
$(document).on("operation","element",function(){
//do something
})
示例1:
$(document).on("click",".edit-gp",function(){
console.log("You have clicked the edit button.")
})
示例2:
$(document).on('hide.bs.collapse','.api_info_div', function () {
$(this).prev().find("code").find("i").attr("class","glyphicon glyphicon-plus");
})
Mark一下,查找方便哈