日期:2014-05-18  浏览次数:20532 次

js获取textarea 文件内容报错
<script language="javascript">
function test1(){
var con=content.innerText;
window.alert(con);

}
</script>
  </head>
  
  <body>
   <textarea rows="20" cols="20">  
   </textarea>
    <input name="mytest" type="button" onclick="test1()" value="测试"/>
  </body>
</html>

错误:var con=content.innerText;
求解答,谢谢!

------解决方案--------------------

<script language="javascript">
 function test1(){
 var con=document.getElementById("mytest");
 window.alert(con);
 
}
 </script>
   </head>
   
   <body>
    <textarea rows="20" cols="20">  
    </textarea>
     <input id="mytest" name="mytest" type="button" onclick="test1()" value="测试"/>
   </body>
 </html>
 

应该这样写吧..