call、apply、caller、callee ...js知识点整理

非内联属性css的获取

window.getComputedStyle(myDiv, null).backgroundColor

或者

window.getComputedStyle(myDiv, null).['backgroundColor']

ff下还可以:

document.defaultView.getComputedStyle(myDiv,null).width 

字符串中'\'在innerHTML中的妙用

  先看如下例子

var str = 'hello\

  world';

console.log(str);

  在控制台输出:

hello        world 

  中间是8个空格,不清楚为什么会是8个空格,不过可以利用字符串之间加'\'可以换行并且只会多空格这一特点来构造js中较长的innerHTML,例如:

var a = document.getElementById('mydiv');

var b = document.createElement('div');

b.innerHTML = "<input type='button' id\

  ='btn' value='press' />";

a.appendChild(b)

  

你可能感兴趣的:(apply)