嗨,我無法觸發我的代碼的簡單事件委託,所選DIV內的DOM元素是動態創建的。無法觸發事件委託
<div class="holder" style="-moz-user-select: none;">
<a class="jp-previous page1"> previous</a>
<a class="page">1</a>
<span class="jp-hidden">...</span>
<a class="page jp-current">2</a>
<a class="jp-next page1 jp-disabled">next </a>
</div>
以下是我的JS代碼,我正在就緒塊內執行。
jQuery("div[class=holder]").on('click',function() {
alert('i am here');
});
你的語法是錯誤的'jQuery的(文件)。在( 'click','div [class = holder]「,function(){..});' - 也使用類選擇器而不是屬性sele ctor所以'jQuery(document).on('click',「.holder」,function(){..});' –
@ArunPJohny:已經嘗試過它不工作太 –
然後嘗試使用類選擇器,如我所說更新的評論 –