[jQuery] Dynamically created elements do not trigger event handlers
When I insert a content to a page by using jQuerys append and after
methods, those newly created elements do not trigger any javascript
events as expected.
var cont = $('<a>').attr('href', 'http://
goto.somewhere.org').append('go to...');
cont.click(handler);
function handler() {
alert($(this).attr('href'));
return false;
}
This should prevent the browser to move on the page, but it does not.
Is it a fact that dynamically created content cannot trigger JS events?