Js解决兼容的方法
1. ||
Var dd=document.documentElement.clientWidth||document.body.clientWidth
2. if()else{}
if(window.getComputedStyle){
csss=window.getComputedStyle(aa,null)
}else{
csss=aa.currentStyle
}
console.log(csss)
3. try{} catch(err){}
必须在报错的条件下,和if else比较性能上比较差,不在万不得以的情况下不使用
只读可写
只读: 只能获取不能修改
可写:可以修改的
Null和undefined的区别
Null和undefined都表示没有值
Null 是这个东西是天生存在的但是没给值。
如果我们需要清除浏览器变量的内存需要赋值null
比如
var aa=document.getElementById("aa")
console.log(aa.parentNode.parentNode.parentNode.parentNode) null
Undefined 这个东西压根就不存在的是人为定义的并且没赋值。
1. var a;undefined
2. Div.aa undefined
元素节点的树状图
Document>documentElement>body>tagName
offsetLeft/offsetTop 结合运动
滚动轮播