1

I am trying to make my new website more interactive so have decided to lift some javascript from my old website which used to make the body background in CSS change color when a button is pressed. Now i have added all the code into my new website it just doesn't work at all, I have no idea why,

Here is my HTML

<input id="bodycolorgreen" type="button" value="Green">

Here is my Javascript

$(document).ready(function () {

  $("#bodycolorgreen").click(function () {
    $("body").css("background-color", "green");
  });
});

, Currently my CSS code for body is;

body {
  background-color:black;
}

Basically all I am trying to do is when the button named "bodycolorgreen" is pressed I want it to change the page background to green.

Here is my Linking pages just in case I have lined them wrong.

<link rel="stylesheet" href="stylesheet.css" type="text/css">
<script type="text/javascript"  src="javascript.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
1
  • 2
    FYI, you could press F12 in browser on windows, you'll discover a completly new world, awesome! Commented Apr 6, 2014 at 12:23

1 Answer 1

5

Since your script file is using jQuery, it has to be included first

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<script type="text/javascript"  src="javascript.js"></script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.