我有两个 div,id 分别是 firstCard 和 resultCard。
var newHeight = document.querySelector('#resultCard').clientHeight;
document.querySelector('#firstCard').style.height = newHeight;
alert(document.querySelector('#resultCard').clientHeight);
alert(document.querySelector('#firstCard').clientHeight);
我想将 firstCard 的高度调整为等于 resultCard。我尝试的方法不起作用,我的警报指示两个不同的值(resultCard 为 432,firstCard 为 400)。
有什么我想念的吗?
编辑:缺少 = newHeight + "px"; 还必须在我的 CSS 中设置高度:自动。
最佳答案
document.querySelector('#firstCard').style.height = newHeight + "px";
关于jquery - 使用jss将等效大小设置为div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35326043/