JQuery background switcher - Task 7


Working with jQuery is an easy way of gaining greater understanding of the JavaScript language. Each added function is for the most part self-explanatory allowing even inexperienced programmers great control over their desires for dynamic website designs. My jQuery background switcher demonstrates a small amount of that power with very simple functions.


The task consisted of two parts; setting a random background color and setting a specified background color. However I decided to merge the two parts together into a single program with all behaviors spread out over three buttons and a text field. Seen below are the demands supplied by the institution.

  1. Usage of Math.random() and push() to get and set values of an array of colors.
  2. jQuery's css() function to set an elements background color.
  3. jQuery's ready() handler to determine if the entire document has been loaded.
  4. Load jQuery in minified format from Googles CDN.

Following these criteria, I created listeners for each button press, that either set the color to the last specified or used a randomized selection of color from the array either once or with one second intervals.

Final product
Final product