Very nice Gilles!

Works fine in Safari 2.04. One little thing though: Safari is the only 
browser I know that doesn't trigger a click or does not focus the 
associated form element when clicking on the label. That always annoys me.

One could argue Safari users do not know better anyway, but here's an 
attempt to fix that (untested):

$('label').click(function() {
     var associated = this.htmlFor && $('#' + this.htmlFor)[0] || 
$(this).find('input');
     if (associated) {
         if (associated.type == 'checkbox' || associated.type == 'radio') {
            associated.checked = !associated.checked;
         } else {
             associated.focus();
         }
     }
});


That would work with explicit labels (for/id) or implicit labels 
(<label><input /></label).

-- Klaus


Webunity | Gilles van den Hoven schrieb:
> Hi guys, i've made a new plugin and added it to SVN. It is still in beta 
> (== bugs) so don't use yet untill fully tested.
> 
> This plugin actually started out as a remake of the CRIR (Checkbox Radio 
> Input Replacement) code found on the websites of Chris Erwin, Yeduha 
> Kratz and Kawika.org. I wanted to make a version which used the power of 
> jQuery to create thesame effects, but then a little bit better. When i 
> finished my early draft code, it worked on both CHECKBOX and RADIO 
> elements, and was 4.9kb in size (uncompressed). Right about then, i got 
> the idea to combine my "old" jButton code (which used IMG tags and SRC 
> attributes to create simple buttons) with this code, and code a solution 
> which could be used to add a :hover class to almost any element. Well, 
> here you have it; 17.3Kb in size, 4kb compressed and even smaller 
> GZIP'd, an all-in-one solution to fix most of your problems.
> 
> Demo page:
> http://gilles.jquery.com/cssHover/
> 
> Please test and let me know if there are any bugs. If not, i'll commit 
> it to SVN.
> 
> -- Gilles
> 
> 
> _______________________________________________
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
> 

-- 
Klaus

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to