天天看點

解決動态生成input無法觸發click事件的問題

<input type="button" class="delServer" value="删除伺服器">
$('.delServer').click(function() {
    alert("ok");
});      
原因:      
異步導緻綁定事件失敗。


解決方法:      
使用全局綁定事件
$(document).on("click",".delServer",function(){
    alert("ok");
});