gpt4 book ai didi

jquery - 为谷歌制作所有传出链接 noindex

转载 作者:太空宇宙 更新时间:2023-11-04 09:46:55 25 4
gpt4 key购买 nike

我的网站上有太多外向链接。我想让它们都 no index 用于谷歌。我不想为每个链接写 rel="no index"...

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

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

然后

<div class="noindexlinks">

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

website

最佳答案

您不能分配 html属性来自 css .

然而,您可以使用任意 css 来完成您想要做的事情类和一些jQuery .

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

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

  • 写下你的jQuery代码, demo 使用 attr方法

NOINDEX 是一个meta标签,你要找 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>

关于jquery - 为谷歌制作所有传出链接 noindex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39422120/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com