点击一个div隐藏另一个div
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>点击一个div隐藏另一个div</title> <script type="text/javascript"> function shwoOrHidden(){ if(document.getElementById("d1").style.display=='block'){ document.getElementById("d1").style.display='none'; document.getElementById("d2").style.display='block'; }else if(document.getElementById("d1").style.display=='none'){ document.getElementById("d1").style.display='block'; document.getElementById("d2").style.display='none'; } } </script> </head> <body> <div id="d1" style="height:150px; width:150px; border:1px solid #009900; display:block; position:absolute;" onclick="shwoOrHidden()"> </div> <div id="d2" style="height:150px; width:150px; border:1px solid #FFFF00; display:none; position:absolute; left:200px;" onclick="shwoOrHidden()"> </div> </body> </html>