Random : colorChange()
Javascript Code
+ 0 likes
Please Register to submit score.
| Average Score | 0.0 (of 0 scores) |
| Date Added | Jan 03, 2009 |
| Last Updated | Jan 03, 2009 |
| Tags | change color javascript random |
Description
This snippet changes the color of an element which is selected from a list when called (OR it can change the color of an object to a specified color).
To Setup:
Edit line:
to your list of colors to randomly pick from (6 digits necessary per color) e.g.
To Use:
For specified color change - Your HTML should look like this:
(NOTE: obviously replacing the "<div" tag with the tag for what you need, "colorHere" with your color, "ID of element etc." is self explanatory :) and onclick for whatever event to trigger.)
For random color change - Your HTML should look like this:
(NOTE: obviously replacing the "<div" tag with the tag for what you need, "ID of element etc." is self explanatory :) and onclick for whatever event to trigger.)
Colors currently MUST have 6 characters - but that's a standard number for a Hex Color Code anyway.
Tested in Firefox and IE.
To Setup:
Edit line:
| Code: |
| b='505050 6633FF 000000 765981 149387 999999 666666 666999 FFF5CF' ; |
| Code: |
| b='color1 color2 color3'; |
To Use:
For specified color change - Your HTML should look like this:
| Code: |
| <div onclick='javascript:colorChange("colorHere", "ID of the Element to change the color of")'> |
For random color change - Your HTML should look like this:
| Code: |
| <div onclick='javascript:colorChange("rand", "ID of the Element to change the color of")'> |
Colors currently MUST have 6 characters - but that's a standard number for a Hex Color Code anyway.
Tested in Firefox and IE.






