[英]Enlarge textarea onClick
Can anyone please let me how to Enlarge textarea while using OnClick function or how to increase the rows on onClick? 谁能让我在使用OnClick功能时扩大文本区域或增加onClick的行数?
regards balkar 问候巴尔卡尔
If you can set pixel or column sizes (instead of using the rows
and cols
attributes), you can use the :focus
CSS pseudo-class : 如果可以设置像素或列的大小(而不是使用
rows
和cols
属性),则可以使用:focus
CSS伪类 :
HTML: HTML:
<textarea id="myarea"></textarea>
CSS: CSS:
textarea#myarea { width: 100px; height: 20px; }
textarea#myarea:focus { width: 500px; height: 200px; }
depending on the layout, it's sometimes attractive to give the focused textarea position: absolute
so it floats above the other elements in its enlarged state. 视布局而定,有时将焦点对准的textarea
position: absolute
是很有吸引力的position: absolute
,使其以放大状态浮动在其他元素的上方。
If you wanna use onClick, add an onClick Handler via JavaScript: 如果要使用onClick,请通过JavaScript添加onClick处理程序:
<html>
<body onLoad="load();">
<textarea id="t1">foo</textarea>
<script>
function load(){
document.getElementById("t1").addEventListener("click",function(){
this.setAttribute("rows","50");
},false);
}
</script>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.