使用JavaScript获取CSS值我知道我可以集通过JavaScript获得的CSS值,如:document.getElementById('image_1').style.top = '100px';但是,我能到达当前特定的样式值?我已经阅读了元素的整个样式,但是如果没有必要的话,我不想解析整个字符串。
3 回答
绝地无双
TA贡献1946条经验 获得超4个赞
getComputedStyle().
var element = document.getElementById('image_1'),
style = window.getComputedStyle(element),
top = style.getPropertyValue('top');添加回答
举报
0/150
提交
取消
