我有一些動態創建的按鈕:ID動態創建的按鈕未定義
<input type='button' id='remove_"+ii+"' class='removeItem' value='remove'>
的二值是無關緊要的。
我想要聽這些按鈕被點擊,並做一些事情:
$(document).on('click',$('.removeItem'),function(){
alert($(this).attr('id'));
});
然而,該警報是給我「未定義」。至少我期望看到「remove_」..
我在想什麼?
'$(文件)。在( '點擊',$()函數( ){'應該是'$(document).on('click','。removeItem',function(){'...不應該使用'$('。removeItem')' –