<!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>
當(dāng)我點(diǎn)擊這個(gè)元素的時(shí)候,怎么顯示在前面或者后面或者里面?
19990000
2017-10-04 23:34:26