这对于某人来说应该很容易,我似乎无法得到正确的语法。我有以下代码,我相信70%的代码可以用循环表示:请有人给我启发一下吗?Javascript循环语法
function AddNewEmail(){
var jFilesContainer = $("#emails");
var jUploadTemplate = $("#email-templates div.template");
var jUpload = jUploadTemplate.clone();
var strNewHTML = jUpload.html();
var intNewFileCount = (jFilesContainer.find("div.template").length + 1);
jUpload.attr("id", ("emailedit[" + intNewFileCount + "]"));
strNewHTML = strNewHTML
.replace(
new RegExp("::FIELD1::", "i"),
intNewFileCount
)
.replace(
new RegExp("::FIELD2::", "i"),
intNewFileCount
)
.replace(
new RegExp("::FIELD3::", "i"),
intNewFileCount
)
.replace(
new RegExp("::FIELD4::", "i"),
intNewFileCount
)
.replace(
new RegExp("::FIELD5::", "i"),
intNewFileCount
)
.replace(
new RegExp("::FIELD6::", "i"),
intNewFileCount
)
.replace(
new RegExp("::FIELD7::", "i"),
intNewFileCount
)
.replace(
new RegExp("::FIELD8::", "i"),
intNewFileCount
)
.replace(
new RegExp("::FIELD9::", "i"),
intNewFileCount
)
.replace(
new RegExp("::FIELD10::", "i"),
intNewFileCount
)
.replace(
new RegExp("::FIELD11::", "i"),
intNewFileCount
)
.replace(
new RegExp("::FIELD12::", "i"),
intNewFileCount
)
;
jUpload.html(strNewHTML);
jFilesContainer.append(jUpload);
}
什么不行,问题是什么? – 2011-05-09 09:25:12