Translate this javascript to jquery- 1
How would you write this in jQuery?:
...
window.onload = init;
function init(){
document.getElementById("div").onclick = setBackgroundColor;
}
function setBackgroundColor(){
document.getElementById("div").style.backgroundColor = getRandomColor();
}
function getRandomColor(){
var randomNumber = Math.floor(1+Math.random()*2);
switch(randomNumber){
case 1:
return "blue";
break;
case 2:
return "red";
break;
}
}
...