当我点击这个元素的时候,怎么显示在前面或者后面或者里面?

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加按钮</title>
    <style>
        .box{
            width: 50px;
            height:50px;
            border:1px solid #000;
        }
    </style>
</head>
<body>
<div class="wrap box">111</div>
<input type="text" id="addvalue">
<button type="button">添加</button>
</body>
<script>
    var add=document.getElementsByClassName("add")[0];

    add.addEventListener("click",function(e){
        e.preventDefault();
        var divs=document.createElement("div");

        var addValue=document.getElementById("addvalue").value;

        var textDiv=document.createTextNode(addValue);

        divs.appendChild(textDiv);

        divs.setAttribute("class","box");

//      怎么显示在class:wrap元素的前面 或者后面 还有里面?
 })
</script>
</html>


19990000
浏览 1193回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript