GridView 的编辑框,如何在获得焦点时,自动变长,在失去焦点后又变回来呢

解决方案 »

  1.   

    <input type="text" onfocus="this.style.width='200px';" onblur="this.style.width='100px';" style="width:100px;" /> 
      

  2.   

    <html>
    <head>
    <script type="text/javascript">
    function setStyle(x)
    {
    document.getElementById(x).style.width=500px;
    }
    </script>
    </head><body>First name: <input type="text"
    onfocus="setStyle(this.id)" id="fname" /></body>
    </html>
      

  3.   

     <script type="text/javascript">
        function cls(){
    //捕获触发事件的对象,并设置为以下语句的默认对象
            with (event.srcElement)
            //如果当前值为默认值,则清空
                document.getElementById("test").style.width = "200";
    }
    function res(){
    //捕获触发事件的对象,并设置为以下语句的默认对象
    with(event.srcElement)
    //如果当前值为空,则重置为默认值
        document.getElementById("test").style.width = "";
    }
    </script>
    <input value="填写您的昵称" onfocus="cls()" onblur="res()" id="test"/>