Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: checkbox & css

  1. #1
    Senior Coder jcdevelopment's Avatar
    Join Date
    Oct 2007
    Location
    Cowboy Nation
    Posts
    2,182
    Thanks
    174
    Thanked 257 Times in 257 Posts

    checkbox & css

    Is there a way to have the checkbox checked when rolled over, or is that a JS thing?

  • #2
    Regular Coder
    Join Date
    Jun 2004
    Posts
    495
    Thanks
    0
    Thanked 82 Times in 80 Posts
    JavaScript
    Code:
    <input type="checkbox" onmouseover="this.checked=(this.checked)? false : true;">

  • #3
    Regular Coder
    Join Date
    Sep 2007
    Location
    Raleigh, NC
    Posts
    273
    Thanks
    7
    Thanked 59 Times in 52 Posts
    Worth mentioning that if you plan on doing this on a group of checkboxes it'd be best to strip out the inline JS and do it in an included file through event handlers.

    Code:
    $$('checkbox-rollovers').forEach(
          addEvent('onmouseover', 
                   function() { this.checked=(this.checked)? false : true }
          )
    );
    The above is a Prototype-like syntax but the logic would be the same if you were doing it without a Library.
    Last edited by vtjustinb; 10-29-2007 at 08:29 PM.


  •  

    Posting Permissions

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