Javascript 单击按钮更改其他div的背景色?
错误是什么?我想在单击#按钮时更改.navbar inverse的背景色Javascript 单击按钮更改其他div的背景色?,javascript,html,button,colors,background,Javascript,Html,Button,Colors,Background,错误是什么?我想在单击#按钮时更改.navbar inverse的背景色 3结尾缺少分号。划船 单击回调结束时缺少“});” 它在这里起作用,问题一定是在其他地方,就是这样。 $(document).ready(function() { $('#button').click(function() { var colors = ["#16A085","#2980b9","#34495e"] var rand = Math.floor(Math.random()*colors.l
它在这里起作用,问题一定是在其他地方,就是这样。
$(document).ready(function() {
$('#button').click(function() {
var colors = ["#16A085","#2980b9","#34495e"]
var rand = Math.floor(Math.random()*colors.length);
$('.navbar-inverse').css("background-color", colors[rand]);
});
$(document).ready(function() {
$('#button').click(function() {
var colors = ["#16A085","#2980b9","#34495e"]; // here
var rand = Math.floor(Math.random()*colors.length);
$('.navbar-inverse').css("background-color", colors[rand]);
}); // here
});