I’m creating a link in jquery when you click on another link.
The problem is that I want to generate an alert when you click on this new link, but does not trigger the action!
$('#test').click(function() {
$("<div/>").html('<a href="#" id="remove">Remove</a>').appendTo("#results");
});
$('#remove').click(function() {
alert('lol');
});
link to the code: http://jsfiddle.net/LARef/
You should use delegate
http://jsfiddle.net/LARef/1/