这个难题,外国的问答站不细致深入了解其中含义,就关闭了,像国内精英请教吧
<!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>