PotD: Color Changing Fun

June 15, 2017

by — Posted in Coding

For today’s project, I used a little Javascript to change the colors on my page.

The color changing page when it’s first loaded.
One result after pushing that last button…








The online class I’m taking on Javascript said the best way to learn is by looking at example code and modifying it to understand how things happen, which is what I did in this case.  I saw an example for changing the background color, and I expanded it to change the colors of other items on the pages.  Perhaps I should have changed the buttons so their colors could be changed too!

I’ve been learning how to program in Python, so switching to Javascript is a little brain twister for me.  For example, I’m used to writing for loops as:

for i in range(6):
      <insert actions here>

In Javascript, the same for loop has a lot more items and punctuation involved:

for (var i = 0; i < 6; i++) {
      <insert actions here>;

Also, apparently I’m having the hardest time remembering what CSS to use to center items on a page!  And it seems like every time I look it up, I have to do something different depending on the type of thing I am centering.  *sigh*  I’ll get it someday…but today is not that day.

Leave a Reply

Your email address will not be published. Required fields are marked *