单击按钮时 jquery 背景颜色更改

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9821691/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 11:20:50  来源:igfitidea点击:

jquery background color change on button click

jquerycolorsbackground

提问by user1022585

Why doesnt this work?

为什么这不起作用?

jquery

查询

$("#button").click(function(){ 
 $("go").css("background-color","yellow");
 });

html

html

<table><tr id=go bgcolor=#010609><td>hello</td></tr</table>
<input type=button id=button>

回答by mgraph

gois an id :

go是一个 id :

$("#button").click(function(){ 
    $("#go").css("background-color","yellow");
});

回答by Tim B James

Your selector for gois wrong.

您的选择器go是错误的。

Try

尝试

$('#go').css({backgroundColor: 'yellow'});