这里的功能:如何在每次调用函数时在JavaScript中创建唯一的ID?
function addAttachment() {
if (allowed_attachments <= 0)
return alert("', $txt['more_attachments_error'], '");
document.getElementById("uploadBtn").onchange = function() {
document.getElementById("uploadFile").value = this.value;
};
setOuterHTML(document.getElementById("moreAttachments"),
\'<div class="upload_attachment">\
<input id="uploadFile" placeholder="File">\
<label class="custom-file-input">\
<input type="file" id="uploadBtn" name="attachment[]">\
</label></div><span id="moreAttachments">\
</span>\');
allowed_attachments = allowed_attachments - 1;
return true;
}
UploadBtn和UploadFile需要是唯一的每次,我该怎么办呢?我真的坚持
如何唯一必须“独一无二”的呢?全球独一无二?一个用户在一定时间内足够独特? – deceze
简答:生成一个足够大的随机数。 – deceze
你可以查看[Mongoh's Truly Uniquie ID](https://github.com/mongoh/tuid) –