+ 1

Coding issue

I have a question when your code shows a white background how do you change it to black in a sequence like go from the Title to the game after you press a button

10th Jun 2025, 2:21 PM
Brian O'Connell
Brian O'Connell - avatar
49 odpowiedzi
+ 5
Hi, let's start with some tips. 1: To make your code cleaner, there is a CSS tab where you can include styles for the various buttons. 2: Put all visible aspects of your webpage between the <body> opening tag and its closing counterpart </body>. Do not put anything after the closing HTML tag </html>. On to the question: To change the background color when we press a button, we can include an onclick="()" attribute on any button. Let's try it with your Wise button. First, give it an ID so that it can be used for making other changes with JavaScript later on. Next, add our onclick function with a name and value: <button id="wise-button" class="Wise-button" onclick="changeBackgroundColor('black')"> Now is the tricky part I suggest you take the Javascript course to better understand the example below In the code playground's JS tab copy and paste this. function changeBackgroundColor(color) { document.body.style.backgroundColor = color; } The changeBackgroundColor function takes an argument named "color." It modifies the CSS property of the body element (document > body) to set its background-color style to whatever was passed in as the color parameter. Please like this comment if you find it helpful. If you really like it. Mark it best for others can find it easily. Detailed comments like these takes a lot of time. I appricate likes for my time :) Let me know if you have any more questions - Happy Coding!
10th Jun 2025, 3:50 PM
Chris Coder
Chris Coder - avatar
+ 4
Brian O'Connell can you plz show your code so we can help you
10th Jun 2025, 2:26 PM
Aysha
10th Jun 2025, 2:54 PM
Aysha
+ 3
Fantasitc! - Happy coding
10th Jun 2025, 8:55 PM
Chris Coder
Chris Coder - avatar
10th Jun 2025, 2:41 PM
Brian O'Connell
Brian O'Connell - avatar
+ 2
Yw. Please continue to ask questions, that is one of the best ways to learn. You don't have to complete the entire course to learn what I did. Just google search onclick function and how to style with JS. And it will explain it all. There are keywords that you will see highlighted in the codes. Search what they mean to get an understanding about what they do. Every part of the code has a purpose. Coding is like connecting dots. But each of these dots does something different - Happy coding!
10th Jun 2025, 6:04 PM
Chris Coder
Chris Coder - avatar
+ 2
on line 32 in the css tab put capital W instead of lower case.
10th Jun 2025, 6:40 PM
Chris Coder
Chris Coder - avatar
+ 1
Thanks
10th Jun 2025, 3:01 PM
Brian O'Connell
Brian O'Connell - avatar
+ 1
You will have to continue to learn and practice JS to get a understanding. Perhaps complete the courses first then come back to your project
10th Jun 2025, 5:13 PM
Chris Coder
Chris Coder - avatar
+ 1
Thanks
10th Jun 2025, 5:20 PM
Brian O'Connell
Brian O'Connell - avatar
+ 1
Thanks
10th Jun 2025, 6:06 PM
Brian O'Connell
Brian O'Connell - avatar
+ 1
Yes. When coding you have to be percise and detailed. How do you want to change the color and when? You can change it by inline code in html with the style attribute. You can change it with CSS Or with JS. When do you want to change it? After click? During a hover, After pressing other buttons. Many possiblites.
10th Jun 2025, 6:18 PM
Chris Coder
Chris Coder - avatar
+ 1
You've styled the buttons already. Now simply change the background-color. .Wise-button { background-color:black;
10th Jun 2025, 6:23 PM
Chris Coder
Chris Coder - avatar
+ 1
example has been provided, please make the change in your css class .Wise-button { }
10th Jun 2025, 6:26 PM
Chris Coder
Chris Coder - avatar
10th Jun 2025, 6:31 PM
Chris Coder
Chris Coder - avatar
+ 1
I noticed you using different Case for your class. You have .wise-button in <style> And Wise-button in the css tab. Put all styles in the CSS tab help prevent confusion and overwritten property: values
10th Jun 2025, 6:36 PM
Chris Coder
Chris Coder - avatar
+ 1
Line 32 you have .wise-button { It should be .Wise-button{
10th Jun 2025, 6:43 PM
Chris Coder
Chris Coder - avatar
+ 1
https://sololearn.com/compiler-playground/WL2iKcPOnZus/?ref=app This code does not have the proper change.
10th Jun 2025, 6:44 PM
Chris Coder
Chris Coder - avatar
+ 1
your text is also black... because your class in html does not match the same case as the class in your CSS
10th Jun 2025, 6:52 PM
Chris Coder
Chris Coder - avatar