Skip to content

Instantly share code, notes, and snippets.

@nelsonJM
Created April 9, 2014 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nelsonJM/10261306 to your computer and use it in GitHub Desktop.
Save nelsonJM/10261306 to your computer and use it in GitHub Desktop.
jQuery: Disable checkboxes
(function($) {
$('#framesize-section').html('<input id="enable-checkboxes" type="checkbox"><label>Enable</label>');
var noNews = '<input type="checkbox" id="no-news"><label>No thanks</label>';
var yesNews = '<input type="checkbox" id="yes-news"><label>Yes, please</label>';
$('#message').append(noNews);
$('#message').append(yesNews);
var enable = $('#enable-checkboxes');
var disabledInputs = $('#accessories-section').find('input[type=checkbox]');
disabledInputs.prop('disabled', true);
enable.on('click', function(){
var $toggle = $(this);
if ($toggle.prop('checked') === true){
disabledInputs.prop('disabled', false);
} else {
disabledInputs.prop('disabled', true);
}
$('#no-news').click(function() {
$('#quotebuilder-form').attr('action', 'thanks.html');
});
$('#yes-news').click(function() {
$('#quotebuilder-form').attr('action', 'no-thanks.html');
});
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment