- Posted On 6 August 2014
- By
- In Programming
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.
- Tags :
- ASP.NET
- MVC
- jQueryJavascript
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.
Visual Studio 2008 Shell and TFS integration
Visual Studio 2008 Shell and TFS integration is the problem for all newbies of BIDS and TFS. Here is the solution.
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.
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.
Best CSS Gradient background generator tools online
Here are some best CSS gradient background code generator online tools using which you can create a cross browser css code for gradient backgrounds.