複製されたテーブルからのクリックイベントによって複製された行があります。それが属性名を設定できない理由かどうかはわかりませんが、クリアするために2回目に複製されました。
var ipCount = 2;
$("#input_form").on("click", "#add_input_param", function() {
$('#input_param tr').eq(1).clone().find('input').val('').end()
.appendTo('#input_param > thead').trigger('creat')
.find('*[name]')
.each(function() {
//alert(i);
alert( $(this).attr('name'));
$(this).setAttribute = ('name', 'new_name');
});
ipCount++;
});
私の質問は次のとおりです。1.属性を取得できるのに設定できないのはなぜですか。2. .each(function(){}) が、このクリック イベントによって作成された最後の行だけをループするようにします。(現在表示されているようにすべてが表示されるわけではありません)
どんな助けでも私はそれを感謝します。ありがとうございます。
これは私の HTML ブロックです:
<h4>
3.3.5 Input Parameters
</h4>
<table id="input_param" >
<thead>
<tr>
<th>Parameter</th>
<th>Data Type</th>
<th>Required</th>
<th>Brief description</th>
<th>Location in Request</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" name=":ops1/6/1/1_param" /></td>
<td><input type="text" name=":ops1/6/1/1_type" /></td>
<td>
<select id="required" name=":ops1/6/1/1_required">
<option value="Mandatory" >Mandatory</option>
<option value="Optional" >Optional</option>
<option value="Conditional" >Conditional</option>
</select>
</td>
<td><textarea name=":ops1/6/1/1_desc"></textarea></td>
<td>
<select name=":ops1/6/1/1_location">
<option value="Header" >Header</option>
<option value="Body" >Body</option>
<option value="Query_param" >Query Parameter</option>
<option value="Resource_uri" >Resource URI</option>
</select>
</td>
</tr>
</tbody>
</table>
<input type="button" id="add_input_param" value="+ Add Input Parameter" data-inline="true" /><br />