0
点赞
收藏
分享

微信扫一扫

获取样式

书写经典 2022-07-27 阅读 59

使用 ​​Window.getComputedStyle()​​ 获取指定元素的 CSS 规则的值。

const getStyle = (el, ruleName) => getComputedStyle(el)[ruleName]

getStyle(document.querySelector('p'), 'font-size') // '16px'

举报

相关推荐

0 条评论