SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    set color of checkbox and its text to green if checked and red if it is checked

    I want to set the color of checkbox and its text to green if it is checked and set to red if it is checked.
    How to do that?
    I know how to do that in CSS.
    e.g.
    <td><div class='red'><input type="checkbox" name="choice" value="1" checked>Keyboard is Broken</div></td>
    <td><div class='red'><input type="checkbox" name="choice" value="2" checked>Ack</div></td>
    <td><div class='green'><input type="checkbox" name="choice" value="3" >Ok</div></td>
    How to do that with javascript?

  2. #2
    SitePoint Addict
    Join Date
    Apr 2007
    Posts
    300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use an onclick handler to change the class.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •