I have the following code to create some element:
< 5条回答 萌比男神i (楼主) 2020-12-28 17:10 Because it's dynamic content, you can't bind events like the static content, it will not bind to the elements because they don't appear at the time you bind. So you should bind event like this: $('#parent').on('click', 'a.remove_block', function(events){ $(this).parents('div').eq(1).remove(); }); 0 讨论(0) 查看其它5个回答 发布评论: 提交评论 加载中... 验证码 看不清? 提交回复 热议问题
Because it's dynamic content, you can't bind events like the static content, it will not bind to the elements because they don't appear at the time you bind.
So you should bind event like this:
$('#parent').on('click', 'a.remove_block', function(events){ $(this).parents('div').eq(1).remove(); });