Reset textarea height in javascript

筅森魡賤 提交于 2019-12-01 08:48:55

You could use setAttribute to reset style attribute added automatically during the resize :

document.getElementById('reset').onclick = function(){
    var textarea = document.getElementById('target');
  
    textarea.setAttribute('style','');
    textarea.value = "";
}
<textarea id="target" rows="1" cols="10"></textarea>
<br>
<button id="reset">Reset</button>

Try resetting the style:

document.getElementById("textarea").style.height = "20px";

Just a JQuery version, that I'm using when I close a modal on my project

$("#jobURL").attr("style", "").val("")
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!