【发布时间】:2015-03-29 06:20:16
【问题描述】:
我正在开发一些 CSS 编辑器,并希望能够在单击 <button> 时更改其样式。以下代码不会将background-color 更改为黄色。
$('a').click(function() {
event.preventDefault();
$('button:active').css('background-color', 'yellow');
});
编辑:就我而言,我无法为按钮分配特定的类,因为它是用户可自定义的 html。
【问题讨论】:
-
那么如何在您的案例中停用按钮? css?
-
无需停用,
:active状态可以使用相同的颜色
标签: javascript jquery html css