我有这个代码
HTML:
<tr>
<td>
<select style="text-align:left" type="text" id="prov0" class="prov0" autocomplete='off'>
<option value="blank">-Select Sample1-</option>
<option value="1">A</option>
<option value="2">B</option>
<option value="3">C</option>
<option value="4">D</option>
<option value="5">E</option>
</select>
<td>
<select style="text-align:left" type="text" id="muni0" autocomplete='off'>
<option >-Select Sample2-</option>
</select>
</td>
</tr>
的jQuery
$(document).ready(function () {
let globalId = 0;
function addNewRow() {
let row = $("table tr").last().clone(),
oldId = Number(row.attr('id').slice(-1)),
id = 1 + oldId;
row.find('#prov'+oldId).attr('id', 'prov'+id);
row.find('#muni'+oldId).attr('id', 'muni'+id);
row.find('#brgy'+oldId).attr('id', 'brgy'+id);
row.find('.prov'+oldId).attr('class', 'prov'+id);
$('table').append(row);
globalId = id;
}
$('#prov'+globalProvId).on('change', function() {
--my ajax request here--
});
});
关于改变不会第二次工作。它不会对新附加的tr工作..为什么会这样? .....................................