Jump to content

Javascript Changing background-color


brooke_theperson

Recommended Posts

So, I have a general question. I learned javascript on codecademy, which doesn't teach much just very basic javascript concepts. This leaves me wondering how to do many basic things that could be applied to programs. One general question I have couldmake a program I am working on right now much cooler. My question is, how do use javascript to change the background-color of anything. I do not have a specific code to share, but here is my html:

 

 

<!DOCTYPE html><html><head>    <link rel='stylesheet' href='style.css'/>    <script src='script.js'></script></head><body onclick = "change()"></body></html>

 

My css:

 

 

body{    background-color: blue}

 

My javascript:

 

 

function change(){    }

 

Obviously this is just about as basic as it gets. My questions is how do I write the function to change the background-color? I know it is probably simple, but I have never learned. Please help.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...