第一种方法
通过监听事件
document.body.addEventListener('click',)
代码如下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.index {
width:200px; }
.content {
margin-top:10px;
width:200px;
height:200px;
background:#ccc;
}
</style>
</head>