faqts : Computers : Programming : Languages : JavaScript : Forms : Checkboxes

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

102 of 192 people (53%) answered Yes
Recently 3 of 10 people (30%) answered Yes

Entry

How can I set the background color of a checkbox?
How can I change the background color of a checkbox?

Mar 31st, 2000 10:56
Martin Honnen,


NN4+ and IE4+ allow to set the background color with css
  <INPUT TYPE="checkbox" STYLE="background-color: lime;" ...>

IE4+ and NN6 also allow dynamic change with JavaScript, for instance in 
the onclick handler:

<INPUT TYPE="checkbox" NAME="aCheckBox" VALUE="Kibo"
       STYLE="background-color: lime;"
       ONCLICK="if (this.style && !this.checked) 
                  this.style.backgroundColor = 'lime';
                else if (this.style && this.checked)
                  this.style.backgroundColor = 'red';"
>