gpt4 book ai didi

javascript - 如何设置特定标签的样式

转载 作者:搜寻专家 更新时间:2023-10-31 22:03:08 24 4
gpt4 key购买 nike

我有很多链接看起来像这样:

<a href="http://www.youtube.com/user/nigahiga">Youtube</a>
<a href="http://pinterest.com/pin/41236152807615600/">Pinterest</a>
<a href="https://www.facebook.com/manchesterunited">Facebook</a>
<a href="http://www.youtube.com/user/RayWilliamJohnson">Youtube</a>
<a href="http://pinterest.com/pin/24910604158520050/">Pinterest</a>

我如何才能只设置将链接到 pinterest 的超链接的样式。我试过这个:

$('a').attr('href').contains('pinterest').css('Styling here');

但它不起作用。如何实现?

最佳答案

您可以使用 attribute contains selector :

$('a[href*="pinterest"]').css('color','DeepSkyBlue');

或者更好的是只需要纯 CSS:

a[href*="pinterest"] {  
color: DeepSkyBlue;
}

Fiddle

关于javascript - 如何设置特定标签的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16215797/

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