brooke_theperson Posted April 5, 2015 Share Posted April 5, 2015 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 More sharing options...
Ingolme Posted April 5, 2015 Share Posted April 5, 2015 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 Link to comment Share on other sites More sharing options...
brooke_theperson Posted April 5, 2015 Author Share Posted April 5, 2015 Thanks, when I searched google before I found nothing good, but this makes sense. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now