Open link in new window with Jquery

Posted by mtwallet on Stack Overflow See other posts from Stack Overflow or by mtwallet
Published on 2010-04-09T09:29:25Z Indexed on 2010/04/09 9:33 UTC
Read the original article Hit count: 292

Filed under:
|
|

Hi. I am trying to open a few links in a new window using Jquery rather than _blank so my html remains valid. My code looks like this:

$(document).ready(function() {
    $('a[id="external-url"]').click(function(){
        $(this).attr('target','_blank');
    });
});

This works just fine except when the link is contained within html I have placed on the page using the Jquery load() method. Can anyone explain why and please help with a solution?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about load