gpt4 book ai didi

查询 :contains showing alert for all span

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

我有一个跨度 <span style="font-weight: bold;">Text goes her</span>像这样

$('#contentarea').bind('click',function(e){
e.preventDefault();
if($(e.target).is('span')){
if($(e.target).find(":contains(font-weight: bold;)")){{
alert('bold');
}
}
});

我没有得到实际结果,如果我点击任何 span 文本它会提醒,请帮助我,我需要找出 span 包含 font-weight: bold;

最佳答案

您可以使用属性选择器...(如果您只需要选择包含样式属性的范围作为字体...)

试试这个

$('span[style^="font-"]')

这应该选择样式以 font- 开头的范围

$('span[style="font-weight: bold;"]')

fiddle

关于查询 :contains showing alert for all span,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17524586/

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