Test 3 jQuery - Click to Change Button Background and Text Colours:

00-digit colours
01-digit colours
02-digit colours
03-digit colours
04-digit colours
05-digit colours
06-digit colours
———————————————————
0Total



The colours for the button backgrounds and text are randomly generated by jQuery.

They are requested in the range of 0 (black) to 0xffffff (white). The leading hex digit will then be in the range of 0 to f. If it is a 0 (a 1 in 16 chance), the routine will return a 5-digit (or shorter) string. This is considered to be in an illegal format by most browsers.

To overcome this problem, the mathematical value is compared with 0x100000 and if lower, 0x100000 is added, thus filling in the top digit with a 1. This now guarantees a 6-digit hex string. Whenever this correction has to be made, the word *** CHANGED *** is displayed.

The colour string counts of all lengths are then displayed, above. The five most recent short colours are listed, below.