tags:

views:

35

answers:

2

I want to disable all controls in a page using jquery except controls contained in a particular div.

 $('input,select,textarea,div:not("#viewNotice")').attr('disabled', 'disabled');

I have tried using above selector, but its not working good. Here I am disabling all input, select and textarea controls leaving viewNotive div.

Note: In viewNotice div I have a JqGrid. I dont want to disable jqgrid.

A: 

You should consider using something like a modal layer instead. This would be much simpler in many ways. However, you can try the following:

$(':input').not('#viewNotice :input').attr('disabled', true);

The selector you used selected all divs that did not have an id of viewNotice (amongst other elements). This piece of code selects all input elements (see jQuery's selector API for :input) and excludes all inputs that are contained in #viewNotice afterwards.

elusive
+1  A: 

http://www.jsfiddle.net/Z2wYn/

take a look at this fiddle.

cloudlight