<!doctype html> <html> <head> <script type="text/javascript"> function $(id){return document.getElementById(id)} function oncbody() { $("aa").style.display="block"; } document.documentElement.οnclick=function(e){ e=window.event?window.event:e; var e_tar=e.srcElement?e.srcElement:e.target; if(e_tar.id=="test") { return; } else { $("aa").style.display="none"; } } </script> </head> <body> <br/><br/> <a href="javascript:void(0);" onClick="oncbody()" id="test">aaa</a> <br/><br/><br/><br/> <div id="aa" style="border:#d3d3d3 solid 4px;width:300px; height:250px; display:none; padding:15px; background:#f7f7f7">sdfs</div> </body> </html>
运行代码复制代码另存代码 提示:您可以先修改部分代码再运行 |
转载于:https://www.cnblogs.com/zzybanshanxianqiao/archive/2012/11/15/2771488.html