使用 Jquery 将站点图标添加到链接

发布于 2024-09-15 12:30:48 字数 383 浏览 2 评论 0原文

我刚刚在我的网站上测试了这个 Jquery 脚本 http://cool-javascripts.com/jquery/add-icons-to-your-links-automatically-using-jquery-css.html

目前,该脚本为外部站点创建默认图标。如果能为 Twitter、facebook 和 youtube 等不同的外部网站提供自定义图标,那就太好了,但我正在努力转换脚本来执行此操作。

如果您能提供帮助,请先致谢。

I have just tested this Jquery script with my site http://cool-javascripts.com/jquery/add-icons-to-your-links-automatically-using-jquery-css.html

At present the script creates a default icon for external sites. It would be great to have custom icons for different external sites like Twitter, facebook, and youtube, but I am strugling to convert the script to do this.

Thanks in advance if you can help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

顾挽 2024-09-22 12:30:48

我不知道为什么你需要使用 jQuery - CSS 很好地支持属性选择器。跨浏览器兼容性?

无论如何,您要查找的选择器是 a[href*='youtube.com'],它会选择 hrefyoutube.com 的任何锚点代码>属性。您可以对 Twitter、Facebook 等执行相同的操作,只需将 youtube.com 替换为这些网站的 URL。

I'm not sure why you'd need to use jQuery - CSS supports attribute selectors just fine. Cross browser compatibility?

Anyway, the selector you are looking for is a[href*='youtube.com'] which selects any anchors with youtube.com in the href attribute. You can do the same for Twitter, Facebook, etc by replacing youtube.com with the URL to those sites.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文