Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 单击按钮更改其他div的背景色?_Javascript_Html_Button_Colors_Background - Fatal编程技术网

Javascript 单击按钮更改其他div的背景色?

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

错误是什么?我想在单击#按钮时更改.navbar inverse的背景色

  • 3结尾缺少分号。划船
  • 单击回调结束时缺少“});”

  • 它在这里起作用,问题一定是在其他地方,就是这样。
      $(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
    });