use name attribute for input instead of id for use with label

you need Jquery:

  1.  
  2. <label for="myinput"></label><input name="myinput" type="text" value="text here" />
  3. $('label').live('click', function(e){
  4.         if( $(e.target).is(':input') ) return;
  5.         var i = $(':input[name="' + $(this).attr('for') + '"]')
  6.         i.is(':checkbox') ? i.attr('checked', !i.attr('checked') ) : i.focus().select();
  7.     })
  8.  

Tags :

This entry was posted on Saturday, December 5th, 2009 at 3:54 pm and is filed under Blog. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

 

Leave a Reply


 Top