Change Layer Colors

By Antonio Lupetti on Mar 17, 2008


Use these two simple functions to change text and background colors within a specified layer without reloading the page. Can be used separately or together.

Example 1
Change the background color using a fixed color in the script

» Change Background color

Watch the background color change!

Example 2
Change text and background color with user-selected colors:

Text color:

Background color:

» Change text and background color
Watch the text and background colors change!


  • Created by: Antonio Lupetti
  • Web Site:
  • Posted: March 17, 2008

Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: changeLayerColors.js


Paste this code into the HEAD section of your HTML document.


Paste this code into the BODY section of your HTML document


Blog comments powered by Disqus