我有从文本文件读取并插入元素的脚本,以便它们可以被设置样式和显示。但是,我现在想在一个 DIV 中配对两个元素。这是代码:
var lines = request.responseText.replace(/\r/g, "").split("\n"); // Remove carriage returns (\r) and place text into an array, split at the newline character (\n)
for (var i = 0; i < lines.length; i++) { // Cycle through each line in the array
if (lines[i].length >= 57) { // Check if the current line is lengthy, and if so.....separate function
}
var coup = document.createElement("div"); // Create a div element
coup.id = "line" + i; // Give the div an ID in the form of line0, line1, etc.
coup.innerText = coup.textContent = lines[i]; // Place the current line of text in the div
el_status.appendChild(coup); // Append the div to the status box
}
我希望 line0 和 line1 进入一个 DIV。然后我希望 line2 和 line 3 进入另一个 DIV ......
var coup 不必是 div,我不介意将其更改为 ap、span 或 li。
谢谢!