Color change in a website

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!!

1 Like

Try a Google search:

Change background color of a website with buttons Javascript

I worked. Thanks! This is really helpful.

1 Like


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:

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?

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

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

<script src=""></script>
1 Like

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)

1 Like