Created
April 9, 2014 12:04
-
-
Save nelsonJM/10261306 to your computer and use it in GitHub Desktop.
jQuery: Disable checkboxes
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
(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