头疼
起因
昨天吃坏了肚子,同时听了一晚上舍友的咳嗽,今天在调js的时候,出现了本人无法理解的现象:<
经过
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div style="width: 100px; height: 100px; background-color: purple"></div>
</body>
<script src="test.js"></script>
</html>
var action=function(e){
window.alert();
};
document.querySelector("div").onclick=function(){
document.querySelector("div").innerHTML="<div οnclick='action'>click to see error</div>";
};
当你打开点击两次之后,会在chrome调试窗口的sources一栏里看见两个main.html
.
结果
头疼