Jquery:conatins显示警报所有跨度

编程入门 行业动态 更新时间:2024-10-26 18:20:21
本文介绍了Jquery:conatins显示警报所有跨度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个跨栏< span style =font-weight:bold;>文字以< / span> $ b

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

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

解决方案

使用属性选择器...(如果您只需要选择包含风格属性为字体的范围..)

请尝试此

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

这应该选择以 font -

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

小提琴

I have a span <span style="font-weight: bold;">Text goes her</span> like this

$('#contentarea').bind('click',function(e){ e.preventDefault(); if($(e.target).is('span')){ if($(e.target).find(":contains(font-weight: bold;)")){{ alert('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..)

try this

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

this should select the span with style starting with font-

or

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

fiddle

更多推荐

Jquery:conatins显示警报所有跨度

本文发布于:2023-11-27 16:56:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638838.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:跨度   警报   Jquery   conatins

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!