textarea 自动检测高度换行

let dom = document.getElementById(id);
dom.addEventListener('input',function () {
     dom.style.height = dom.scrollTop + dom.scrollHeight + 'px';
});
        
dom.addEventListener('propertychange',function () {   //兼容IE
    dom.style.height = dom.scrollTop + dom.scrollHeight + 'px';
}
// 传id
function autoHeight(id){
    
    
}

先这么用着,还需要进一步优化。

posted @ 2018-08-10 16:35  下小朋友  阅读(598)  评论(0编辑  收藏  举报