So I am trying to make a simple little Jquery function that changes the background color of the body when you click it. When the body is clicked on, if it is red, change it to orange, else, change it to red.
My code (Yes, I am aware of the issue of having my script, css and html on one page, but this is just a testing ground for this one aspect of my code.)
<!DOCTYPE html>
<html>
<head>
<style>
body {background-color: red}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("body").on("click",(function(){
var color = $("body").css("background-color")
if (color == rgb(255,0,0)){
$("body").css("background-color", rgb(255,165,0) );
}
else{
$("body").css("background-color", rgb(255,0,0) );
}
});
});
</script>
</head>
<body>
<h2>This is a heading</h2>
<p>Some Text</p>
<p>Around</p>
<p>Here<p>
<p>Yep.</p>
</body>
</html>