Skip to content

Instantly share code, notes, and snippets.

Created April 4, 2016 15:51
Show Gist options
  • Save anonymous/43e2c4392ee356b0ef548104a9b1d52a to your computer and use it in GitHub Desktop.
Save anonymous/43e2c4392ee356b0ef548104a9b1d52a to your computer and use it in GitHub Desktop.
Color Changer Project jQuery // source http://jsbin.com/xibete
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<meta charset="utf-8">
<title>Color Changer Project jQuery</title>
</head>
<body>
<button id="button1">Black</button>
<button id="button2">Green</button>
<button id="button3">Red</button>
<button id="button4">Blue</button>
<script id="jsbin-javascript">
var colors = ["black", "green", "red", "blue"];
$("#button1").click(function(){
$("body").css("background-color", colors[0]);
});
$("#button2").click(function(){
$("body").css("background-color", colors[1]);
});
$("#button3").click(function(){
$("body").css("background-color", colors[2]);
});
$("#button4").click(function(){
$("body").css("background-color", colors[3]);
});
</script>
<script id="jsbin-source-javascript" type="text/javascript">var colors = ["black", "green", "red", "blue"];
$("#button1").click(function(){
$("body").css("background-color", colors[0]);
});
$("#button2").click(function(){
$("body").css("background-color", colors[1]);
});
$("#button3").click(function(){
$("body").css("background-color", colors[2]);
});
$("#button4").click(function(){
$("body").css("background-color", colors[3]);
});</script></body>
</html>
var colors = ["black", "green", "red", "blue"];
$("#button1").click(function(){
$("body").css("background-color", colors[0]);
});
$("#button2").click(function(){
$("body").css("background-color", colors[1]);
});
$("#button3").click(function(){
$("body").css("background-color", colors[2]);
});
$("#button4").click(function(){
$("body").css("background-color", colors[3]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment