判断div是否有滚动条

判断div是否有滚动条

var obj=document.getElementById("showDiv")
 
if(obj.scrollHeight>obj.clientHeight||obj.offsetHeight>obj.clientHeight){
    
     
	document.getElementById("hiddenDiv").style.height="15pt";
	console.log('该div有滚动条!')
} 

vue项目中,滚动条恢复初始位置的方法

 this.$nextTick(()=>{
    
    
          let dom = document.getElementById('addContent');
          if(dom!==null){
    
    
            dom.scrollTop = 0;
          }
        })

猜你喜欢

转载自blog.csdn.net/weixin_44582045/article/details/129358651