我尝试通过为代码添加书签来突出显示网页中的所有 nofollow 链接,但它不起作用 有人可以告诉我我做错了什么,这是我的代码:
javascript:var a = document.getElementsByTagName('a');for(var i=0; i<a.length; i++)if (a[i].rel === 'nofollow') {a[i].style.backgroundColor = 'red';a[i].style.fontSize = '2em';}
我希望突出显示页面中的每个 nofollow 链接
您忘记在
for
循环定义之后添加左大括号。工作代码:
var a = document.getElementsByTagName('a');
for(var i=0; i<a.length; i++) {
if (a[i].rel === 'nofollow') {
a[i].style.backgroundColor = 'red';
a[i].style.fontSize = '2em';
}
}