在jQuery库的强大帮助下,如何在另一个窗口中打开我博客上的每个链接?
不是将target="_blank"
放在每个链接上,有没有办法可以使用jQuery来快捷方式?
答案 0 :(得分:4)
答案 1 :(得分:2)
$('a.newWindow').click(function() {
var href = $(this).attr('href');
if(href.length > 0) {
window.open(href);
}
});
或者,只需按正确的方式:
$('a.newWindow').attr('target', '_blank');