我需要更改 js 将文本插入到 html 中的位置,目前它总是放在最后,我需要它在开头插入它并将其他文本向下推。也就是说,如果它插入
<li>1</li>, <li>2</li>, <li>3</li>
它会保持这个顺序我需要最后一个总是首先列出
<li>3</li>, <li>2</li>, <li>1</li>
这是html
<div class="data">
<div class="stackleft" id="p1_stack"></div>
<div class="stackright" id="p2_stack"></div>
</div>
这是JavaScript
function drawStack(isFinal) {
var stackLength = Oscore[currentPlayer].stack.length;
var temp = "";
var tot = 0;
for (var i = 0; i < stackLength; i++) {
var val = Oscore[currentPlayer].stack[i];
temp += "<li>" + val + "</li>";
tot += val;
}
//if(!isFinal){
//temp = '<div class="workingScore">'+scoreTemp+'</div><br>' + temp;
//}
var writeSore = document.form1.game.value - tot;
writeit(writeSore, currentPlayer + "_score");
writeit(temp, currentPlayer + "_stack");
}