赤色を水色の場所に、
水色を赤色の場所に入れ替えたいです
どうやればいいんでしょうか?
<script> function change(){ document.body.insertBefore(document.getElementById("a"), document.getElementById("c")); } window.onload=function(){ div = document.createElement("div"); div.id="a"; div.style.width="100px"; div.style.height="100px"; div.style.cssFloat="left"; div.style.background="red"; document.body.appendChild(div); div = document.createElement("div"); div.id="b"; div.style.width="100px"; div.style.height="100px"; div.style.cssFloat="left"; div.style.background="blue"; document.body.appendChild(div); div = document.createElement("div"); div.id="c"; div.style.width="100px"; div.style.height="100px"; div.style.cssFloat="left"; div.style.background="aqua"; document.body.appendChild(div); div = document.createElement("div"); div.id="d"; div.style.width="100px"; div.style.height="100px"; div.style.cssFloat="left"; div.style.background="yellow"; document.body.appendChild(div); } </script> <input type="button" value="移動" onclick="change()">
「位置」「場所」などキーワードが出ているので何も調べようがないとは思えませんが、調べたこと試したことはないでしょうか
現状だと調べてすぐ出そうな記事の紹介程度になるので質問作ってたり待ってる時間が勿体ないです
回答2件
あなたの回答
tips
プレビュー