8. documentElement具体解析


document.documentElement.clientX

获取浏览器的可视宽度

1
2
3
4
5
6
7
8
9
10
//添加事件监听器绑定点击事件,onclick不可用于事件捕获
element.addEventListener(
"click",
function(){
console.log("haha");
},
false//是否捕获
);

//e.stopPropagation();//阻止时间捕获

事件冒泡与事件委托

对象解构可用于赋值,传参,转换

1
2
3
4
5
6
7
8
9
10
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
var ul=...;
var li=ul.````;
ul.addEventListener("click",function(e){
if(e.target.tagName=="LI"){console.log(e.target.innerHtml);}
});//添加事件委托
1
2
3
4
var axian={
name:"pig",
age:20
};

Author: pkq
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source pkq !
  TOC