我需要通过 javascript 更改 div 的边距。但是没有这样的方法:
document.getElementById('div').style.margin-top = var;
有没有办法做到这一点?我到处都找不到
最佳答案
使用marginTop
,而不是margin-top
document.getElementById('AnIdNotADiv').style.marginTop = value + "px";
关于javascript - 从 div javascript 获取边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7078558/