使用html输入提供的信息

问题描述:

我想使用文本输入中的信息来运行脚本。我如何从html中的文本输入中获取信息?使用html输入提供的信息

+2

有一吨的方式。看到这篇文章http://*.com/questions/11563638/javascript-get-input-text-value –

这个例子可以帮助您:

<html> 
<head> 
</head> 
    <body> 
     <input type="text" id="txt" value="this is text"> 
     <button id="btn" onclick="fun()" >Click me</button> 
     <script> 
      function fun() { 
       var mytext= document.getElementById("txt").value; 
       alert(mytext); 
      } 
     </script> 
    </body> 
</html>