Disable/enable all elements in div [duplicate]
How to make quick disabling/enabling of all the elements in any div (inputs, links and jQ Buttons)?
Links do not have a "disabled" property, so you'll have to work a bit harder.
$('#my_div').find(':input').prop('disabled', true);
$('#my_div a').click(function(e) {
e.preventDefault();
});
To re-activate:
$('#my_div').find(':input').prop('disabled', false);
$('#my_div a').unbind("click");
The :input
selector Selects all input, textarea, select and button elements.
Also see http://api.jquery.com/event.preventDefault/
$('#my_div').find('*').prop('disabled',true);
To re-enable, simply use .removeProp()
http://api.jquery.com/removeProp/
$('div').find('input, a, button').prop('disabled', true);
or maybe all:
$('div *').prop('disabled', true);
精彩评论