Select Page

How to disable all html form elements within a DIV tag using JQuery

NOTE: Please not that the prop JQuery function should be used instead of the attr function in JQuery 1.6 and higher


To disable all input elements within div use the following code:
$(‘#message :input’).attr(‘disabled’, true);

To disable all select elements within div use the following code:
$(‘#message :select’).attr(‘disabled’, true);

To disable all submit buttons within div use the following code:
$(“#message :submit”).attr(“disabled”, “true”);


  • The DIV tags ID is message
  • attr– Access a property on the first matched element.
  • $(“selector“)
  • If disabled is set to false the element won’t be disabled

Leave a reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.