<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<button>点击</button>
<script>
//每个函数里面都有this 环境对象
//普通函数里面this指向window
// function fn(){
// console.log(this)
// }
//window.fn()
const btn = document.querySelector('button')
btn.addEventListener('click',function(){
this.style.color = 'red'
//谁调用,this就是谁
})
</script>
</body>
</html>
14-环境对象
最新推荐文章于 2024-09-14 18:52:56 发布