Created
May 18, 2017 17:12
-
-
Save lizardking8610/2f07f8376cf8af550b2284dc682e6cc4 to your computer and use it in GitHub Desktop.
jQuery: click trigger on input when label clicked
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var labelID; | |
$('label').click(function() { | |
labelID = $(this).attr('for'); | |
$('#'+labelID).trigger('click'); | |
}); | |
//All browsers except IE will do this when you code it this way below: | |
//<label><input id='my_input'/></label> | |
//IE requries this: | |
//<label for='my_input'><input id='my_input'/></label> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment