Javascript Jquery选择元素中具有特定名称的所有内容并替换
目前我有一个用于提交的表格。这是我正在使用的代码块的一个小摘录Javascript Jquery选择元素中具有特定名称的所有内容并替换,javascript,jquery,Javascript,Jquery,目前我有一个用于提交的表格。这是我正在使用的代码块的一个小摘录 <tr class="draggable even"> <td class="choice-flag"> <a title="Drag to re-order" href="#" class="tabledrag-handle"> <div class="handle"> </div> </a> </t
<tr class="draggable even">
<td class="choice-flag">
<a title="Drag to re-order" href="#" class="tabledrag-handle">
<div class="handle"> </div>
</a>
</td>
<td>
<input name="recipe_ingredients[ing][1][ri_id]" data-thmr="thmr_141" type="hidden">
<div class="form-item form-type-textfield form-item-recipe-ingredients-ing-1-quantity" data-thmr="thmr_143">
<label for="edit-recipe-ingredients-ing-1-quantity" data-thmr="thmr_144">Quantity</label>
<input class="form-item-recipe-ingredients-quantity form-text" id="edit-recipe-ingredients-ing-1-quantity" name="recipe_ingredients[ing][1][quantity]" value="" size="8" maxlength="8" data-thmr="thmr_142" type="text">
</div>
</td>
<td>
<div class="form-item form-type-select form-item-recipe-ingredients-ing-1-unit-key" data-thmr="thmr_146">
<label for="edit-recipe-ingredients-ing-1-unit-key" data-thmr="thmr_147">Unit</label>
<select class="form-item-recipe-ingredients-unit-key form-select" id="edit-recipe-ingredients-ing-1-unit-key" name="recipe_ingredients[ing][1][unit_key]" data-thmr="thmr_145">
到
是否有一种方法可以选择和更改元素中与字符串匹配的所有属性,并用我的新名称替换这些属性?我计划使用jqueryclone命令添加新行
谢谢你的帮助 您可以克隆行,然后使用RegExp在HTML内部更改它
但事实上,这里应该有一些模板。请考虑使用把手,或类似的东西。一个JSfiddle显示你目前为止有助于回答这个问题,这将有助于你。
edit-recipe-ingredients-ing-1-unit-key
edit-recipe-ingredients-ing-2-unit-key