为字体粗细设置jQuery属性 [英] Setting jQuery attribute for font-weight

查看:284
本文介绍了为字体粗细设置jQuery属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更改元素的字体粗细.我尝试了以下操作,但似乎不起作用:

I am trying to change the font-weight of an element. I tried with the following but it doesn't seem to work:

$("#opt_" + i).attr("font-weight", "bold");

prop和attr有什么区别?这与我的问题有关吗?

Also what's the difference between prop and attr? Is that something to do with my problem?

推荐答案

使用 .css() >函数而不是.attr()

use the .css() function instead of .attr()

$("#opt_" + i).css("font-weight", "bold")

这篇关于为字体粗细设置jQuery属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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