<INPUT TYPE="text" NAME="" onkeyup="this.value.length>5?this.style.width=200:''">思路

解决方案 »

  1.   

    有个css式样可以控制的,具体的想不起来了!
      

  2.   


    <script>
    var handleMax = function(obj){
    obj.style.width = "6px";
    var ch = obj.value;
    for(var i=0;i<ch.length;i++)
    {
    var n = ch.substr(i ,1); 

    if(/^[\x00-\xff]/.test(n))
    obj.style.width = (parseInt(obj.style.width.split("p")[0]) + 6) +"px" ;
    else
    obj.style.width = (parseInt(obj.style.width.split("p")[0]) + 12) +"px" ;
    }
    };
    </script>
    <input type="text" onkeyup="handleMax(this)" style="width:20px" />
      

  3.   

    多谢楼上的,那么我想实现当input超过一定宽度时让他自动增加一个input并在下一行显示怎么实现
      

  4.   

    用多行编辑器<textarea>不好?@_@
      

  5.   

    td   {   word-wrap:break-word;word-break:break-all;text-overflow:ellipsis;overflow:hidden   }
      

  6.   

    可以去这个网站看看 www.wdfan.cn