Jump to content
Sign in to follow this  
brooke_theperson

Javascript Changing background-color

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.

Share this post


Link to post
Share on other sites

The first two results for this search are useful:

https://www.google.com/?gws_rd=ssl#q=javascript+change+background+color

 

One of the links right to the W3Schools.com reference: http://www.w3schools.com/jsref/prop_style_backgroundcolor.asp

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...