使用jQuery在新窗口中打开所有外部链接
这里是jQuery的新手。 我发现几个网页接近我正在尝试做的事情,但并不完全。 实际上,我认为以下内容应该可行,但是它说:
[@href^="http://"]
无法识别(语法错误)。 有帮助吗?
$(document).ready(function() { $('a[@href^="http://"]').filter(function() { return this.hostname && this.hostname !== location.hostname; }).attr('target', '_blank'); });
谢谢。
不需要@符号。 除此之外,你是金色的。
$("a[href^='http://']")...