Created
August 1, 2012 15:38
-
-
Save norcross/3227943 to your computer and use it in GitHub Desktop.
allow labels to set input for radio and checkbox
This file contains 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
// ************************************************************** | |
// set inputs when clicking labels | |
// ************************************************************** | |
$('div#default_license span.ap_option label[rel="ap_rd"]').each(function() { | |
$(this).click(function() { | |
if($(this).hasClass('disabled-label')) | |
return; | |
var radio_me = $(this).prev('input'); | |
$(radio_me).prop('checked', true); | |
$(radio_me).trigger('change'); | |
}); | |
}); | |
$('div#default_license span.ap_option label[rel="ap_ck"]').each(function() { | |
$(this).click(function() { | |
if($(this).hasClass('disabled-label')) | |
return; | |
var check_me = $(this).prev('input'); | |
var is_check = $(check_me).attr('checked') ? true : false; | |
if (is_check === false) { | |
$(check_me).prop('checked', true); | |
$(check_me).trigger('change'); | |
} | |
if (is_check === true) { | |
$(check_me).prop('checked', false); | |
$(check_me).trigger('change'); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hmm probably safe to assume you have a specific reason for needing this, but this can be accomplished with pure html.
either:
or