我需要根据元素高度切换按钮。尝试了 offsetHeight、clientHeight 和 scrollHeight,这些都不起作用。设置 alert() 用于测试目的,离开返回未定义。
window.onload = function (){
var wrapperHeight = document.getElementsByClassName("panel").offsetHeight;
var innerHeight = document.getElementsByClassName("description-content").offsetHeight;
var button = document.getElementsByClassName("accordion");
if(innerHeight > wrapperHeight){
button.style.display = "block";
}
alert(innerHeight);
}
ABOUTYOU
SMILET
相关分类