gpt4 book ai didi

javascript - 为什么 .getPropertyValue() 不返回 "borderRadius"属性的值?

转载 作者:数据小太阳 更新时间:2023-10-29 05:08:29 24 4
gpt4 key购买 nike

函数如下:

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com