I have a cloned div containing input elements, all of which are disabled. I am trying to use the following JQuery code to remove the disabled attribute of each of the div's children.
clonedElement.children().removeAttr('disabled');
I do not have a ton of JQuery experience, so I am probably misunderstanding the way this is supposed to work. How should I be going about removing the "disabled" attribute from all children of the cloned node?
If it helps, clonedElement was created with the JQuery .clone() method.
HTML I AM USING TO TEST---
<div id="original_item" class="hidden">
<div class="row_submit">
<div class="med_field">
<p>Product:</p>
<select name="product[]">
<option></option>
</select>
</div>
<div class="small_field">
<p>Type:</p>
<select name="type[]">
<option></option>
</select>
</div>
<div class="small_field">
<p>Price:</p>
<input type="text" name="price[]" value="test" disabled="disabled" />
</div>
<div class="small_field">
<p>Quantity:</p>
<input type="text" name="quantity[]" />
</div>
<img onclick="removeItem(this);" title="Remove Item" style="margin: 18px 0 0 12px;" src="icons/cancel.gif" />
</div>
<input type="hidden" name="warehouse_data[]" />
</div>
children
only looks in immediate children and if the clonedElement is not one of med_field/small-field then it would not work.
You can use find()
instead to search for elements beyond immediate children.
i.e.
//for jQuery < 1.6
$("*", clonedElement).removeAttr("disabled");
//or
clonedElement.find("*").removeAttr("disabled");
//for jQuery >= 1.6
$("*", clonedElement).removeProp("disabled");
//or
clonedElement.find("*").removeProp("disabled");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With