请教高手,javascript动态创建的文本框如何指定其宽度和高度

解决方案 »

  1.   

    楼主生成文本框之后可以通过设置文本框对象的style来设置宽、高还有其他属性,如下:<!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>2011-12-09测试</title>
    <script type="text/javascript">
    </script>
    </head><body>
    <form name="form1" method="post" action="1.asp">
    <input type= "button" onclick= "addItem()" value= "ADD"/>  
    <script type= "text/javascript">  
    function addItem()  
    {
    var temp=document.createElement("input");  
    temp.type="text";
    temp.name="answer";
    temp.style.display = "block";
    temp.style.width = "500px";
    temp.style.height = "200px";
    document.form1.appendChild(temp);
    }  
    </script>
    </form>
    </body>
    </html>