getBoundingClientRect()
Element.getBoundingClientRect()
返回一个DOMRect对象,提供了元素的大小以及相对于视口的位置。
getComputedStyle()
window.getComputedStyle(element, [pseudoElt])
返回一个实时的CSSStyleDeclaraton对象,当元素样式更改时,它会自动更新自身。
示例1
const app = document.querySelector('#app');
// 可以获得#app实时的样式
const style = getComputedStyle(app);
示例2:伪类元素
const style = getComputedStyle(app, '::after');
getEventListeners()
getEventListeners(element)
非标准api,chrome提供的在控制台调试使用的api,可以返回元素注册的所有事件。