Skip to Content Skip to Navigation
bobbravo2: @hostgator Sponsored WordCamp Houston (@wordcamphtx) August 7th, I want to be there! #wchtx
bobbravo2: Starcraft 2 is awesome so far

jQuery form toggling

Using jQuery to toggle form elements on or off. The following jQuery code toggles the input areas on or off by adding the disabled attribute to their DOM nodes. Here is the JS BIN version http://jsbin.com/ozogo3/2

$(function() {
$("#disableAll").click(function() {
var button = $(this).val();
if (button == 'Disable All') {
$('input:not(.disb), textarea, table, select')
.attr('disabled', 'disabled');
$("#disableAll").val('Enable All');
} else if (button == 'Enable All') {
$('input:not(.disb), textarea, table, select')
.attr('disabled', '');
$("#disableAll").val('Disable All');
}
});
});

blog comments powered by Disqus