how to display textarea without scrollbar using jsf?

雨燕双飞 提交于 2019-12-24 11:16:41

问题


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

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