htmlページ動的に追加されたコンテンツjsが有効でない問題解決
2348 ワード
html動的生成後、前に定義したjqeuryメソッドは機能しません.
htmlダイナミックにコンテンツを追加するのはよくありますが、何度も出会って、解決策を探してみましたが、しばらくはぼやけていないので、わざわざ記録をしました.
解決策
例1:
例2:
Markちょっと探して、便利ですね.
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ちょっと探して、便利ですね.