Normally, if I wanted to call a function if a link is clicked, I would do this:
$('a').click(function() {
//stuff
});
However, I need to call this function even if the element has been newly added. For example,
$('a').click(function() {
//stuff
});
$(document.body).append($('<a href="http://example.com">This is an example</a>'))
//now when I click that example link, the function isn't called!
How can I make a function that applies to all links? I do not have control of the code that adds the new links, so I can't just set its onclick
when it's added.