Color change in a website


#1

I am making a practice website. I think it would be cool to have to 2 buttons on my website. They would change the background color of the website. I know HTML, CSS, and a fair bit of JQuery and Javascript. How would I go about doing this? Thanks!!


#2

Try a Google search:

Change background color of a website with buttons Javascript


#3

I worked. Thanks! This is really helpful.


#4

Hi,

You can use the onclick function in Javascript to change css or the click function in jQuery.. Have you done the courses? If so you would have an idea on how to code it :wink:

I will let you give it a go and if you need help I can help you :smile:


#5

I know jquery and i could figure it out, my problem is how to make the file that you type jquery in. Is it the same way as a css file?


#6

Yes. Any text editor will do. Save it as .js


#7

adding to @jibblyj point, dont forget to add jQuery to your Html:

<script src="https://code.jquery.com/jquery-2.2.0.js"></script>

#8

As @amanuel2 said don't forget to add jQuery library,

Then from your HTML file you just need to link your jQuery document that you create using script tags..
Make sure both your files (HTML & jQuery ) are in the same directory(folder)