日期:2014-05-18 浏览次数:20489 次
<html> <head> <style type="text/css"> <!-- .mainBox { float: left; height: 300px; width: 100%; } .subBox1 { float: left; height: 300px; width: 50%; background-color:blue; }.subBox2 { padding: 0px; float: left; height: 300px; width: 50%; background-color:black; }.subBox4 { float: left; height: 300px; width: 50%; background-color:red; }.subBox3 { float: left; height: 300px; width: 50%; background-color:green; } --> </style> <script> <!-- // 仅适合IE document.attachEvent("onclick", function(){ _Foo("subBox1") } ); _Foo = function(sDivId){ var oTarget = window.event.srcElement; if( sDivId == oTarget.id ) alert("should do something"); else alert("do nothing"); } --> </script> </head> <body> <div class="mainBox"> <div id="subBox1" class="subBox1"> </div> <div id="subBox2" class="subBox2"> </div> </div> <div class="mainBox"> <div id="subBox3" class="subBox3"> </div> <div id="subBox4" class="subBox4"> </div> </div> </div> </body> </html>