Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable all Element inside a div or table using jQuery

Tags:

I have a table that contains several text box and buttons.I disable my table using jquery by this code:

 $("#tbl").attr("disabled", "disabled"); 

my table become disabled but when I double click on the button it become enable and I can enter characters in my text box too. How I can Disable all control inside a table?

thanks

like image 958
Arian Avatar asked Dec 07 '11 10:12

Arian


People also ask

How do I disable all elements in a div?

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

Can I disable div in jQuery?

Using jQuery The idea is to disable click events inside div with jQuery and CSS. This can be done by setting pointer-events CSS property with the help of jQuery's . addClass() function.

How do I disable all inputs in a form?

It can be be done by using prop() method. Using prop() Method: It is used to set or return the properties and values for the selected elements. Example 1: In this example, the . prop() method is used to disable all input controls inside a form element.

Can we disable whole div?

Nope! Divs can't be disabled. Only form and form elems. Actually in Quirks-mode IE can disable a div , but it only grays button texts, it doesn't prevent events firing.


1 Answers

You must traverse and disable all relevant elements.

$("#tbl").find("input,button,textarea,select").attr("disabled", "disabled"); 
like image 127
Interrobang Avatar answered Oct 08 '22 09:10

Interrobang