jQuery检查字体重量是否正常或粗体 [英] jQuery check if font weight is normal or bold

查看:224
本文介绍了jQuery检查字体重量是否正常或粗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  $(this).css({' font-weight':'normal'}); 

现在我想检查一个元素是否有粗体或正常的字体重量,我该怎么做这个?

解决方案

您可以使用它: $ b

  fontWeight = $(this).css('font-weight')

比较:

  if(fontWeight =='normal'|| fontWeight =='400')
//或
if(fontWeight =='bold'|| fontWeight =='700')


I'm setting the font-weight property with the following code:

$(this).css({ 'font-weight': 'normal' });

Now i want to check if an element has bold or normal font-weight propety, how do i do this?

解决方案

you can get it using:

fontWeight = $(this).css('font-weight')

To compare:

if (fontWeight  == 'normal'|| fontWeight  == '400')
//or
if (fontWeight  == 'bold' || fontWeight  == '700')

这篇关于jQuery检查字体重量是否正常或粗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆