<script type="text/javascript"> function testIECase(name){ alert(document.getElementById(name).value); } </script> <hr /> 在ie中获取第一个匹配txtName的元素,name="txtName"是第一个元素 <button onclick="testIECase('txtName')">test txtName</button> <hr /> 在ie中获取第一个匹配txtPassword的元素,id="txtPassword"是第一个元素 <button onclick="testIECase('txtPassword')">test txtPassword</button> <hr /> <input name="txtName" value="txtName 1"/> <input id="txtName" value="txtName 2"/> <input id="txtPassword" value="txtPassword 1"/> <input name="txtPassword" value="txtPassword 2"/> <hr /> <br /> <code> function testIECase(name){ alert(document.getElementById(name).value); } </code>
?