Lor*_*ion 6 jquery fonts properties
我正在使用以下代码设置font-weight属性:
$(this).css({ 'font-weight': 'normal' });
Run Code Online (Sandbox Code Playgroud)
现在我想检查一个元素是否具有粗体或正常的font-weight propety,我该怎么做?
Mil*_*war 13
你可以使用它:
fontWeight = $(this).css('font-weight')
Run Code Online (Sandbox Code Playgroud)
比较:
if (fontWeight == 'normal'|| fontWeight == '400')
//or
if (fontWeight == 'bold' || fontWeight == '700')
Run Code Online (Sandbox Code Playgroud)