日期:2014-05-16  浏览次数:20317 次

一个简单问题的困惑?
<html>
<head>
<SCRIPT   LANGUAGE= "JavaScript ">
<!--

//-->
</SCRIPT>
</head>
<body>

<input   type= "text "   name= "a "   value= " ">
<input   type= "button "   value= "Click "   onclick= "? ">

</body>
</html>

请问我如何用javascript   获得a的值?

------解决方案--------------------
<html>
<head>

</head>
<body>

<input type= "text " name= "a " value= " ">
<input type= "button " value= "Click " onclick= "? ">
<SCRIPT LANGUAGE= "JavaScript ">
<!--
alert(document.getElementsByName( "a ")[0].value)
//-->
</SCRIPT>
</body>
</html>
------解决方案--------------------
document.getElementsByName( "a "),返回一個數組,
document.getElementsByName( "a ")[0].value 數組的第一個元素的value值