views:

123

answers:

1

New to jQuery here. I've found several web pages that come close to what I'm trying to do, but not quite. Actually, I think the following is supposed to actually work, but it's saying:

[@href^="http://"]

is not recognized (syntax error). Any help?

$(document).ready(function() {
    $('a[@href^="http://"]').filter(function() {
        return this.hostname && this.hostname !== location.hostname;
    }).attr('target', '_blank');  
});

Thanks.

+6  A: 

Hi there,

No need for the @ symbol. Other than that, you're golden.

$("a[href^='http://']")...
btelles
Just to expand on this - the @ is deprecated as of jQuery 1.2.6 and 1.3.x.
Jeff Lamb