我在 page.load 加载了以下 Jquery 代码段
function appendFileSizes() {
var attachmentSize = $j172("#<%= AttachmentsFileSize_HiddenField.ClientID %>").val();
var uploadControlFileList = $j172("#<%=Attachments_HiddenField.ClientID %>").val().split("|");
var files = attachmentSize.split("||");
files.splice(files.length-1, 1);
for (var i = 0; i < files.length; i++) {
var fileInfo = files[i].split("|");
var fileIndex = $j.inArray(fileInfo[0], uploadControlFileList);
if (fileIndex > -1) {
var label = document.createElement("div");
label.setAttribute("class", "contactUsAttachmentFileSize");
label.localName = "fileSize";
label.innerHTML = "(" + bytesToSize(fileInfo[1], 2) + ")";
label.style.fontSize = 10;
var row = $j172("span.ruUploadSuccess:contains('" + fileInfo[0] + "')").parent().parent();
if (!row.find("div.contactUsAttachmentFileSize").length) {
$j172(row).append(label);
uploadControlFileList.splice(fileIndex, 1);
}
}
}
}
问题是它适用于除 IE7 之外的所有浏览器,其中 if ( .find) 不起作用并且我的行每次都被添加,而不仅仅是一次。