1. getComputedStyle
獲取元素樣式液斜,行間樣式也能獲取到
console.log('getComputedStyle' + getComputedStyle(box)['width']);
僅在IE中使用
console.log('currentStyle'+box.currentStyle['left']);
2. js獲取樣式
使用js寫style是給行間樣式添加css佣谐,當(dāng)使用style.left
獲取的是行間樣式居砖,若行間樣式未設(shè)置時楚午,則獲取不到值,js是通過控制標(biāo)簽來控制頁面的,無法直接編寫css
3. offsetWidth
獲取元素寬度content+padding+border
4. clientWidth
元素邊框內(nèi)的區(qū)域
content+padding
5. 變量提升
在函數(shù)中出現(xiàn)變量聲明的時候,會將變量放到當(dāng)前函數(shù)開始的位置
function a(){
var c;
c=123;
console.log(c);
}