Subscribe - It's FREE!!

Stay Connected Here

Stay Updated With Us Here


How to disable all controls of particular div using jQuery

Share with WhatsApp

This post covers information about how to disable all the controls contained by some specific div usng jQuery.

While developing web application you might implement some functionality in which you need to disable controls of some container or div such as view and then edit functionality so to implement this you can use this simple jQuery code.

To disable all controls of specific div you can find all those controls like following.

$("#divName input,select,textarea,button")

In above we have given all expected control types seperated with comma as selector so it will give all controls of type input,select,textarea,button contained by divName div.

Once you got all controls to make them disable you can write a simple jQuery code like below.

$("#divName input,select,textarea,button").prop("disabled", true);

If you want to make it re-enable following code can be used

$("#divName input,select,textarea,button").prop("disabled", false);

While reading about the same I came to know several other ways such as getting all controls by $("divName *") or $("divName").find("*") with their performance pros and cons e.g. find works better than * selector etc. but I will not go into the details of that and will keep that job with you. :-)

There are already this kind of solutions available on sites like StackOverflow but still shared here as if you came here while reading some other post on this site it will add this information in your repository.

Check out the live fiddle of the same code below.

Hope you have liked this simple but useful post. Do share your thoughts in comment section below.

If you enjoyed this post take 5 seconds to share it! Be Socialable. :-)

Share with WhatsApp

Posts To Read Next

Typewriter - Automatic TypeScript Template generation from C# classes in Visual Studio

Typewriter, an extension for visual studio that generates TypeScript files from C# code files using TypeScript templates. Convert your C# model classes to TypeScript automatically.

How to call click or any event only once in jQuery

Know how to execute an click event or any event only once for any element in jQuery. Perform action only once and even not required to unbind event.

Top 10 Visual Studio things which can boost developers coding speed

Visual Studio 2012 provides some coding features by which you can code faster if use them properly. This post will cover top 10 things among them to boost your development speed.

Copy changed data in table from one database to another in SQL stored procedure

How to copy or merge changed data in table from one database to another having same schema is the topic of this post.

Assembla - Free and private repository to manage your source code online with SVN subversion hosting

With Assembla you can share source code with others online. Free & Private source code repository with SVN Subversion, Git & Perforce Hosting.

Your opinion is valuable for us! Comments, suggetions are welcome.

Submit your Email Id to stay updated with us and get notified with our new posts. It's FREE!
Vu 32'' TV Vu 24'' TV
We know this popup is disturbing you!
But We would greatly appreciate if you share us with your friends below!

It will not take more than 2 seconds but will motivate us greatly to write more,share more!