var liList = document.querySelectorAll('ul li');for(var i =0; i < liList.length; i++){
liList[i].onclick=function(){// console.log(i);
console.log(this.innerHTML);}}
而如果改成这样我们就可以获得我们想要的东西
如果出现全局作用域的话一般指向是window对象
还有就是出现在对象的方法之中,通常指向该对象
var o ={
name:"小明",
age:17,
sayHello:function(){
console.log(this);}}```![在这里插入图片描述](https://img-blog.csdnimg.cn/20200828202034436.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0VXSlJRS0pSUQ==,size_16,color_FFFFFF,t_70#pic_center)