在容器最前面添加DOM元素 parent.insertBefore(new, parent.children[0])

        //判断容器当前有没有子级元素,如果没有直接appendChild就行了;
        if (p.children[0]) {
          p.insertBefore(span, p.children[0]);
        } else {
          p.appendChild(span);
        }
原文地址:https://www.cnblogs.com/hello321/p/7819314.html