textarea高度的增加和减小控制
2018年04月15日
⁄ 综合
⁄ 共 784字 ⁄ 字号
小 中 大
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title> 增加减小textarea的高度 </title>
- <meta name="generator" content="editplus" />
- <script language="Javascript">
- <!--
-
- function resizeEditor(change) {
- var newheight = parseInt(document.getElementById('code').style.height, 10) + change;
- if(newheight >= 100) {
- document.getElementById('code').style.height = newheight + 'px';
- }
- }
- //-->
- </script>
-
- </head>
-
- <body>
- <textarea id="code" style="width:99%;height:100px;"></textarea>
- <input type="button" value=" + " onclick="resizeEditor(100)" />
- <input type="button" value=" - " onclick="resizeEditor(-100)" />
- </body>
- </html>