【发布时间】:2013-03-18 05:55:02
【问题描述】:
这两天我用谷歌搜索过这个网站,也浏览过这个网站,但没有发现类似的问题。我是 jQuery 新手,希望这不会与其他帖子重复。
$(this).css("font-weight", "bold"); //this works
$(this).css({"font-weight":"bold"}); //this works as well
$(this).css("font-weight", "normal"); //this doesn't work
$(this).css({"font-weight":"normal"}); //this doesn't work either
为什么不能将文本字体粗细设置为 NORMAL(在我的情况下)?我使用的是 Firefox 17.0.1,但是将字体设置为正常的功能在早期版本的 Firefox 中也无法使用。
更新:
昨晚我的问题终于解决了,在浏览了这个网站后,发现了一个很相似的东西。一些人不得不在 HTML sn-p 中搜索 <b> 和 </b>,我通过
使用这个:
"$(this).find('strong, b').css('font-weight', 'normal')"
而不是:
“$(this).css('font-weight', 'normal')”。
问题解决了!感谢大家昨天帮助我。
【问题讨论】:
-
你签入萤火虫了吗???? css 可能不适用于 dom,因为
Normal字体意味着没有 css 只是用作默认字体。 -
它似乎工作正常? jsfiddle.net/bXyd8
-
真的不行。但是当我检查它时,“看起来”粗体的折叠实际上是“不粗体”。我使用的方法是:fontWeight = $(this).css('font-weight'); if (fontWeight == 'bold' || fontWeight == '700') { alert("bold"); $(this).css("font-weight","normal"); }
-
这个 $(this).css("font-weight", 400); 怎么样
-
$(this).css("font-weight", 400); //这也失败了。但是问题是由于我的 PHP 代码中“”和“”设置的粗体字体造成的吗?