日期:2014-05-16 浏览次数:20399 次
<html> <head> <script language="javascript"> function print(){ var a=myform.name.value; alert(a); } </script> </head> <body> <form name="myform"> <input type="text" name="name" id="nn" /> <input type="button" name="button" value="获取" onclick="print()" /> </form> </body> </html>
<html> <head> <script language="javascript"> function print(){ var a=document.getElementById("nn").value; alert(a); } </script> </head> <body> <form> <input type="text" name="name" id="nn" /> <input type="button" name="button" value="获取" onclick="print()" /> </form> </body> </html>