Problems with jQuery

Problems with jQuery
0.0 0

#1

I am trying to change the color of my HTML background by using Jquery every time i click a button. This is my code $(document).ready(function(){
var colors = [’#16a085’, ‘#27ae60’, ‘#2c3e50’, ‘#f39c12’, ‘#e74c3c’, ‘#9b59b6’, ‘#FB6964’, ‘#342224’, “#472E32”, “#BDBB99”, “#77B1A9”, “#73A857”];
var color = Math.floor(Math.random() * colors.length);

$(".btn").click(function() {

$("body").css("background-color", color);

});
})


#2

Try this:

$(document).ready(function(){
var colors = ['#16a085', '#27ae60', '#2c3e50', '#f39c12', '#e74c3c', '#9b59b6', '#FB6964', '#342224', "#472E32", "#BDBB99", "#77B1A9", "#73A857"];
var color = "";

$(".btn").click(function() {
color = colors[Math.floor(Math.random() * colors.length)];

$("body").css("background-color", color);

});
})

Also make sure you have a link to jquery in your html code.