<html> <head> <title></title> <script> function plusDiv() { var div1 = document.getElementById('div1'); var div2 = document.getElementById('div2'); if (div1.style.zIndex > div2.style.zIndex) { div1.style.zIndex = div1.style.zIndex - 2; } else { div2.style.zIndex = div2.style.zIndex - 2; } } </script> </head> <body> <div id="div1" style="position:absolute;z-index:1;width:100;height:100;background-color:#FF0000;left:0;top:0"></div> <div id="div2" style="position:absolute;z-index:2;width:100;height:100;background-color:#00FF00;left:10;top:10"></div> <input type="button" onclick="plusDiv()" value="交替底层出现" style="z-index:100;position:absolute;left:300" /> </body> </html>?