原本紫蓝色的框,为何点击方框内任意位置换成红色?
代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
div{
width: 300px;
height: 100px;
border: 1px solid blue;
}
</style>
</head>
<body>
<div>
<p>
<ul>
<li>
好
</li>
</ul>
</p>
</div>
</body>
<script>
document.getElementsByTagName('div')[0].onclick = function () {
this.style.border="1px solid red";
}
</script>
</html>