日期:2014-05-16 浏览次数:20352 次
<!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" lang="gb2312"> <head> <title> test</title> <script src="jquery.min.js"></script> <script type="text/javascript"> function show_s(evt){ $('#test').show(); var e=(evt)?evt:window.event; if (window.event) { e.cancelBubble=true; } else { e.stopPropagation(); } } function init(){ $("body").bind("click", function(){ $('#test').hide(); }); } $(document).ready(function(){ init(); }); </script> </head> <body> <div onclick="show_s();">dddddddddddddddddddddddddd</div> <div id="test" style="display:none;">mmmmmmmmmmmmmmmmmmm</div> </body> </html>
//阻止事件冒泡 var ev = window.event || arguments.callee.caller.arguments[0]; if (window.event) { ev.cancelBubble = true; } else { ev.stopPropagation(); } //