- Posted On 6 August 2014
- 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.
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.
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.
Swagger - Powerful Opensource Framework for RESTful API
With a Swagger-enabled API, you get interactive documentation, client SDK generation and discoverability. Swagger Editor allows you to generate code, documentation with ease.