Jon P
Jon P

Reputation: 19772

How do I select all disabled decendants using jQuery

I want to be able to select all disabled decandants of a given element, in my particular instance a table cell and then enable them.

NOTE that there may be elements that are not "inputs"

I have tired the following with no success

$("#myCell [disabled='disabled']").removeAttr('disabled')

and

$("#myCell [disabled='disabled']").attr('disabled','')

Upvotes: 0

Views: 156

Answers (2)

Gart
Gart

Reputation: 2336

My solution:

$("#myCell *[disabled='disabled']").removeAttr("disabled");

This * selector means 'all elements'

Upvotes: 0

Paolo Bergantino
Paolo Bergantino

Reputation: 488394

Try:

$('#myCell :input:disabled').removeAttr('disabled');

The :input selector is going to select all input elements, and the :disabled selector is going to select elements that are disabled. You could probably just have the :disabled selector but it doesn't hurt to have both and is probably marginally faster to do so.

Upvotes: 3

Related Questions