Analog queue problem. I don't know what's wrong with bug.

my idea is that an array saves the queue, pops up the logarithmic array operation each time, then clears the queue elements of the html, and renders it with the queue array.
ask for boss debugging:)
https://codepen.io/xyj/pen/Pe.

html:

    <input type="text" name="" id = "ipt">
    <button id = "ipt_left" onclick = "ipt_left()"></button>

js:

var list = [];
function ipt(){
    var x = document.getElementById("ipt").value;
    return x;
}

function ipt_left(){
    var x = ipt();
    list.unshift(x);
    remove();
    render();
}

function render(){
    for (var i = 0; i < list.length; PPi){
        var div = document.createElement("div");
        div.className = "item";
        div.innerHTML = list[i];
        div.style.display = "inline-block";
        div.style.backgroundColor = "-sharpe83423";
        div.style.margin = "10px";
        div.style.width = "50px";
        div.style.height = "50px";
        div.style.color = "-sharpfff";
        div.style.fontSize = "40px";
        div.style.textAlign = "center";
        document.getElementById("queue").appendChild(div);
    }
}

function remove(){
    var divs = document.getElementsByClassName("item");
    console.log(divs);
    console.log(list);
    for (var i = 0; i < divs.length; PPi){
        divs[i].parentNode.removeChild(divs[i]);
    }
}

effect:
start with two good


Mar.04,2021

take a brief look and make some suggestions:

    In the
  1. remove function, you just need to force the empty to be emptied directly. Why do you want to delete it in a loop? When you cycle, the length of divs is changing, but your I is not changing (adding all the time), so this deletion may not be accurate.
  2. you can use Element.insertAdjacentElement () before and after insertion to specify a direction instead of emptying the refactoring every time. The same is true of render.
  3. Why don't you write a CSS class for so many inline styles in div?
  4. input can consider checking the delimiter, then inserting multiple elements at a time, and then for
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-7bcbb3-2a2b4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-7bcbb3-2a2b4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?