Input width Adaptive _javascript technique

Source: Internet
Author: User
<textarea id="runcode6733"><! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "content=" text/html; charset=gb2312 "/> <title> Untitled document </title> <script language=" JavaScript "> Function checklength ( which) {var maxchar=100; var otextcount = document.getElementById ("char"); icount = Which.value.replace (/[^\u0000-\u00ff]/g, "AA"). Length; if (Icount<=maxchar) {otextcount.innerhtml = "<font color= #FF0000 >" + icount+ "</font>"; Which.style.border = ' 1px dotted #FF0000 '; which.size=icount+2; else alert ("Please do not exceed" +maxchar); } </script> </pead> <body> <input name= "Words" size= "2" maxlength= "onkeyup=" Checklength (this ) "/> <span id=" char ">0</span> characters </body> </ptml></textarea>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

<center> input height fixed, automatic widening <input type= "text" > TextArea width fixed, automatic elevation <textarea type= "text" ></t Extarea>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

Thanks to the Netizen "Liufabin" raised on the issue of not supporting FF, the first in the FF tested under the support of the second high degree of adaptive does not support, I found a jquery plug-in online, the plug-in address is: http://plugins.jquery.com/ Project/autogrow need to use the JS file address for
Http://img.jb51.net/jslib/jquery/jquery.autogrow.js
<textarea id="runcode56094"><! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "content=" text/html; charset=gb2312 "/> <title>input width adaptive 2009-05-28</title> <script type=" Text/javascript "src=" http:/ /img.jb51.net/jslib/jquery/jquery-1.3.2.min.js "></script> <script type=" Text/javascript "src=" http:// Img.jb51.net/jslib/jquery/jquery.autogrow.js "></script> <script type=" Text/javascript "> $ (function () {$ ("#textarea"). autogrow (); }) </script> </pead> <body> <!----> <textarea id= "textarea" will appear when the minimum is high 80PX ></textar ea> </body> </ptml></textarea>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.