jquery - how to get data attributes of dynamically generated element -


while throwing dynamic content (through ajax) server, have following response.

<a data-contentid="1">some content</a> ... 

i have binded click event using live. problem in click event, unable data attributes, manually attaching not option case. ideas?

example code:

 $('a.delcontent').live("click",function () {              var cid= jquery.data(this, "contentid");              alert(cid);  //undefined             return false;         }            ); 

try inside click event handler:

$(this).data('contentid') 

works in jsfiddle: http://jsfiddle.net/mk2zy/


Comments