问题
I want inputTextarea auto growing when being typed.But I don't want scrollbar. I have done overflow: hidden ,it's not showing scroll but it's also not auto growing.
<h:inputTextarea id="ta1" cols="25" style="overflow: hidden"/>
please give me reply.
回答1:
The auto growing textarea is not a standard feature of the HTML <textarea> element as generated by the JSF <h:inputTextarea>. This is usually been achieved by adding some shot of JavaScript code. Here's a basic kickoff example.
<h:inputTextarea ... onkeyup="autoGrow(this)" />
with
function autoGrow(textarea) {
if (textarea.clientHeight < textarea.scrollHeight) {
textarea.style.height = textarea.scrollHeight + "px";
}
}
来源:https://stackoverflow.com/questions/11008696/how-to-display-textarea-without-scrollbar-using-jsf