Originally textarea only a row high, with the increase in the number of input words, the default growth, usually used in mobile product input
Use Oninput better than onkeyup for mobile phones
<id= "Txtcontent" class= "j_comment_in comment-input" rows = "1" oninput= "Resizetextarea (' txtcontent ')" style= "Overflow-y: hidden; " placeholder = "I also say ..." ></ textarea >
//min. heightvarMinrows = 1; //maximum height, scroll bar appears overvarMaxRows = 6; functionResizetextarea (ID) {vart =document.getElementById (ID); if(T.scrolltop = = 0) t.scrolltop=1; while(T.scrolltop = = 0){ if(T.rows >minrows) T.rows--; Else Break; T.scrolltop= 1; if(T.rows <maxRows) T.style.overflowy= "hidden"; if(T.scrolltop > 0) {t.rows++; Break; } } while(T.scrolltop > 0){ if(T.rows <maxRows) {T.rows++; if(T.scrolltop = = 0) t.scrolltop=1; } Else{t.style.overflowy= "Auto"; Break; } } }
Monitor textarea input text changes, let textarea height self-growth