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

Written by Ian Carnaghan · 21 sec read >

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

Last Updated On March 21, 2018
Written by Ian Carnaghan
I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment. In my spare time I teach undergraduate classes in web development. Profile

Leave a Reply

Notify of