Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I disable all elements inside a fieldset in jQuery?

I have 2 <fieldset>s on my page, but one of them should have all of it elements disabled depending on some user's choice.

The fieldsets contain text inputs, selects, and links. Is there a way to disable all of them instead of disabling them one by one?

like image 938
André Miranda Avatar asked Apr 23 '09 13:04

André Miranda


1 Answers

What about using the children selector?

$("#myfieldeset").children().attr("disabled", "disabled");

You can also filter the children selection:

$("#myfieldeset").children("a,input");
like image 114
kgiannakakis Avatar answered Oct 21 '22 05:10

kgiannakakis