SO - 16691511
by Arun P Johny
HTML
<a href='http://example.com'>This one works! (if you click, it will preventDefault)</a><br/>
JavaScript
$(document).on('click', 'a', function(e) {
//stuff
e.preventDefault();
console.log('click', this)
});
$(document.body).append($('<a href="http://example.com">This one doesn\'t because I just added it :(</a>'))
//now when I click that example link, the function isn't called!