0

我的网站上有太多传出链接。我想为谷歌制作它们no index。我不想写rel="no index"每个链接...

(< a href="..." rel="noindex, nofollow" >...< /a > )

我可以创建一个class并用css写这个吗?

接着

<div class="noindexlinks">

这可能吗?或者我可以为此编辑我的 htaccess 吗?

网站

4

1 回答 1

1

您不能通过 分配html属性css

但是,您可以使用任意css类和一些jQuery.

  • 首先,创建一个任意类,比如no_follow_links

  • 将此类分配给各种<a>标签,例如,<a class="no_follow_links" href="http://address.com">

  • 编写jQuery代码,使用attr方法进行演示

NOINDEX是一个元标签,你正在寻找nofollow你的<a>标签。

$(".no_follow_links").each(function(){
	$(this).attr("rel","nofollow");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a class="no_follow_links" href="http://google.com">Link</a>
<a class="no_follow_links" href="http://bing.com">Link</a>
<a class="no_follow_links" href="http://yahoo.com">Link</a>

于 2016-09-10T03:32:58.513 回答