2015-05-12 46 views
0

jQuery的上單擊事件不工作在動態添加自定義標籤jQuery的上單擊事件不工作在動態添加自定義標籤

我的代碼是

$("[addtoShip='yes']").on('click', function() { 
     alert('Ship added') 
    }); 

HREF爲<a href="#" addtoShip='yes' myVal="10235">添加更多發貨</a>

我使用.on努力但仍然是不工作

+4

可能是'$(document).on('click','[addtoShip ='yes']「,function(){' –

+1

http://stackoverflow.com/questions/203198/event-binding -on-dynamic-created-elements –

+0

@BrijeshBhatt,我測試過,但也沒有運氣 –

回答

1
$(document/CommonParentSelector).on('click', "[addtoShip='yes']", function() { 
    alert('Ship added') 
}); 
+0

它工作$(document).on('click',「[densitybtn ='yes']」,function(){})但我沒有得到CommonParentSelector –

相關問題