Linked Questions

Popular Questions

replaceChild' on 'Node': parameter 1 is not of type 'Node'

Asked by At

Hi I've been checking my codes but I just have no idea why is the error is happening. Apparently I'm not getting my child values from my ttList.

<ul id = "ttList" style="list-style: none; padding-left: 0"></ul>
function creatTT()
{
    var input = document.getElementById("integer").value;
    var li;
    var value;

    if(/^[1-9]$/.test(input) == true)
    {
        for(var i = 1; i <= 9; i++)
        {
            li = document.createElement("li");
            value = document.createTextNode(input + " x "  + i  + " = " + (input* i));
            li.appendChild(value);
            document.getElementById("ttList").appendChild(li);
        }
    }
        var ttList = document.getElementById("ttList").childNodes[0];
        ttList.replaceChild(input, ttList.childNodes[0]);
}

Related Questions