函数如下:
function lastmenuborder() {
var articleparent = document.getElementById('article').parentNode;
var articlestyle = window.getComputedStyle(articleparent,null).getPropertyValue('borderRadius');
alert (articlestyle);
}
我没有得到任何值,但父节点的 css 是:
div#mainbody div.placeholder {
border-radius: 3px;
}
我必须更改什么才能返回“3px”?非常感谢所有帮助;我仍然是 JavaScript 的新手。
最佳答案
对于 getPropertyValue()
,您使用连字符而不是驼峰命名法。
这在 Chrome 中有效...
.getPropertyValue('border-radius');
但是 Firefox 似乎需要使用这种语法的特定 Angular 落......
.getPropertyValue('border-top-left-radius');
关于javascript - 为什么 .getPropertyValue() 不返回 "borderRadius"属性的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10803023/