日期:2014-05-16 浏览次数:20311 次
<!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"> <body> <div id="dv" style="border:1px solid red;width:100px;height:100px;"> <div id="top" style="border:1px solid green;width:30px;height:30px;"></div> <div id="top1"></div> <div id="top2"></div> <div id="top3"></div> </div> <script> document.getElementById("top").onclick=function(){ alert(1); if(event && event.stopPropagation) event.stopPropagation(); else window.event.cancelBubble=true; } document.getElementById("dv").onclick=function(){ this.innerHTML='<div id="top" style="border:1px solid green;width:30px;height:30px;"></div>'; //don't write JS om innerHTML } </script> </body> </html>