var currentIndex = ++$indextemp;
alert(currentIndex);
var $divTemp = $("#interModel").clone();
$divTemp.find("[name^=results]").each(function(i){
var oldName = $(this).attr("name");
var newName = oldName.replace(/[0~9]+/,currentIndex);
$(this).attr("name",newName);
});
$divTemp.appendTo("#interTd");replace后没有把oldName中的数字替换为currentIndex,大家看看是什么问题
alert(currentIndex);
var $divTemp = $("#interModel").clone();
$divTemp.find("[name^=results]").each(function(i){
var oldName = $(this).attr("name");
var newName = oldName.replace(/[0~9]+/,currentIndex);
$(this).attr("name",newName);
});
$divTemp.appendTo("#interTd");replace后没有把oldName中的数字替换为currentIndex,大家看看是什么问题
是的,按你这样写可以, /[0~9]+/ 与 /[0-9]+/区别是什么? /[0~9]+/貌似也可匹配数字