jQuery的:包含显示所有跨度的警报 [英] Jquery :contains showing alert for all span
本文介绍了jQuery的:包含显示所有跨度的警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的跨度<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');
}
}
});
我没有得到实际结果,如果我单击它将警告的任何跨度文本,请帮助我,我需要找出该跨度包含 font-weight:bold;
i am not getting the actual result, if i click any span text it will alert,please help me, i need to find out the span contains the font-weight: bold;
推荐答案
您可以使用属性选择器...(如果您只需要选择包含样式属性作为字体的范围.)
you can use the attribute selector...(if you just need to select the span containing the style attribute as font..)
尝试
$('span[style^="font-"]')
这应该选择以font-
或
$('span[style="font-weight: bold;"]')
这篇关于jQuery的:包含显示所有跨度的警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文