New to jQuery here. I've found several web pages that e 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.
New to jQuery here. I've found several web pages that e 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.
Share Improve this question edited Dec 9, 2009 at 3:24 Justin Johnson 31.3k7 gold badges66 silver badges89 bronze badges asked Dec 9, 2009 at 3:14 Jeff LambJeff Lamb 5,8754 gold badges39 silver badges57 bronze badges1 Answer
Reset to default 9No need for the @ symbol. Other than that, you're golden.
$("a[href^='http://']")...
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744375623a4571171.html
评论列表(0条)