<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<!--当点击时背景颜色变为黄色-->
<script>
function changeColor(id){
id.style.backgroundColor='yellow';
}
</script>
</head>
<body>
<p οnclick="changeColor(this)">JavaScript事件处理</p>
</body>
</html>
未点击
点击后