reset password
Author Message
gbrandon218
Posts: 2
Posted 12:29 May 24, 2015 |

I need help on the second part of the lab changing the color of the backgorund i'm not sure on how to start the function.
 

cesar714
Posts: 30
Posted 12:49 May 24, 2015 |

For the second part of the lab. When you click the button, the button will call a function. Let's call the function button(). Inside the function you will need to use properties. On lecture 8 slide 12 you can read about them and on slide 13 an example is provided. With properties you can change the background color. Next you want to change the paragraph color as well. In order to do this you need to use document functions. On lecture 8 slides 21-28 you can read and see examples of document functions. Finally, you will want the button to toggle between the dark and bright themes each time the button is clicked. To do this you will need an if-statement. For the button to work you will need to write code in the if statement that will say if variable is true than display the dark theme else the variable is false display the bright theme.

function button(){

if(true){dark theme}

else{bright theme}

}

Goodluck.

gbrandon218
Posts: 2
Posted 17:51 May 24, 2015 |
cesar714 wrote:

For the second part of the lab. When you click the button, the button will call a function. Let's call the function button(). Inside the function you will need to use properties. On lecture 8 slide 12 you can read about them and on slide 13 an example is provided. With properties you can change the background color. Next you want to change the paragraph color as well. In order to do this you need to use document functions. On lecture 8 slides 21-28 you can read and see examples of document functions. Finally, you will want the button to toggle between the dark and bright themes each time the button is clicked. To do this you will need an if-statement. For the button to work you will need to write code in the if statement that will say if variable is true than display the dark theme else the variable is false display the bright theme.

function button(){

if(true){dark theme}

else{bright theme}

}

Goodluck

thank you for the help, however im still having trouble i've tride a couple of way however this is the closest i've gotten to your previous ouline for the code 

function colorFunction() {
        var document.body.style.backgroundColor = "white";
        if (document.body.style.backgroundColor == "white") {
        document.body.style.backgroundColor = "Gray"
        }
        else {
         document.body.style.backgroundColor = "White"
        }

cesar714
Posts: 30
Posted 19:14 May 24, 2015 |

Take the first part out

var document.body.style.backgroundColor = "white";

That should fix it