$.expr[':'].external = function(obj){
if (! obj.href.match (new RegExp ("^http"))) {
return (false);
}
return (true);
}
I have a custom jquery selector above. It checks for an external link. I call it using:
$('a:external')
.on ('click', function (e) {
do_stuff ();
});
Above works great. But below does not. Basically I need to do the below because I load in some content via ajax and I need to check for external links still. I figured the below would work but no luck. If I were to remove the :external from below it works on all links as expected. But adding the selector of :external doesn't produce an event when I click on the link. Any ideas?
$('body')
.on ('click', 'a:external', function (e) {
do_stuff ();
});