<div id="main"> <div style="background-color:coral;" id="myRedDIV"></div> <div style="background-color:lightblue;" id="myBlueDIV"></div> <div style="background-color:lightgreen;" id="myGreenDIV"></div> <div style="background-color:pink;" id="myPinkDIV"></div> </div> <p>点击“尝试一下”按钮,改变四个 DIV 的顺序:</p> <button onclick="myFunction()">尝试一下</button> <script> function myFunction() { document.getElementById("myRedDIV").style.order = "4"; document.getElementById("myBlueDIV").style.order = "3"; document.getElementById("myGreenDIV").style.order = "1"; document.getElementById("myPinkDIV").style.order = "2"; } </script> <p><b>注意:</b>Internet Explorer 和 Safari 不支持 order 属性。</p>