javascript - 单击时将按钮文本更改为粗体

标签 javascript jquery

我试图使按钮的文本在单击时变为粗体。我尝试使用这个问题的建议:How to make a text in font/weight style bold in JavaScript

http://jsfiddle.net/14tjwvnq/

function boldButton(){
    $('#btn').style.fontWeight = '700';
}

最佳答案

在 jQuery 中,您需要使用 css方法:

$('#btn').css( 'font-weight', '700' );

jsFiddle

关于javascript - 单击时将按钮文本更改为粗体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27799256/

相关文章:

javascript - 是否可以使用该 iframe 内页面中存在的 javascript 更改 iframe src?

javascript - 根据用户权限渲染 react 组件

javascript - 错误: $injector:modulerr Module Error Failed to instantiate module printStation due to: Error: [$injector:modulerr

jquery - 在 jQuery 中结合 .text() 和 .css() 方法

javascript - 两个选择表列

javascript - Select2 未应用

javascript - 如何禁用 elevateZoom?

javascript - Emberjs - 一起使用 CollectionView 和 ItemController

jQuery UI 对话框内容显示在页面本身中

javascript - Jquery keydown 函数