当您使用 selected.jquery.min.js 和 choose.css 在选择选项后生成动态新的 div 时,问题就出现了,因此当时 javascript 不起作用
$tr.find("input,select").attr("name", function()因为只有两个标签添加输入和选择
我建议在其中添加 javascript 行
$(document).ready(function($)
{
$('#sif_roba1').next('div').attr("id","sif_roba1");//Chane Code
$('#sif_roba1').next('div').attr("name","sif_roba1");
// trigger event when button is clicked
$("button.add").click(function()
{
// add new row to table using addTableRow function
addTableRow($("table"));
// prevent button redirecting to new page
return false;
});
// function to add a new row to a table by cloning the last row and
// incrementing the name and id values by 1 to make them unique
function addTableRow(table)
{
// clone the last row in the table
var $tr = $(table).find("tbody tr:last").clone();
// get the name attribute for the input and select fields
$tr.find("input,select,div").attr("name", function()
{
// break the field name and it's number into two parts
var parts = this.id.match(/(\D+)(\d+)$/);
// create a unique name for the new field by incrementing
// the number for the previous field by 1
return parts[1] + ++parts[2];
// repeat for id attributes
}).attr("id", function(){
var parts = this.id.match(/(\D+)(\d+)$/);
return parts[1] + ++parts[2];
});
// append the new row to the table
$(table).find("tbody tr:last").after($tr);
$tr.hide().fadeIn('slow');
// row count
rowCount = 0;
$("#table tr td:first-child").text(function() {
return ++rowCount;
});
// remove rows
$(".remove_button").on("click", function() {
$(this).parents("tr").fadeOut('slow', function () {
$(this).remove();
rowCount = 0;
$("#table tr td:first-child").text(function() {
return ++rowCount;
});
});
});
};
});
好的,在该页面上更改没有其他内容...