<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>getElementById.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <!--<link rel="stylesheet" type="text/css" href="./styles.css">--> </head> <body> <form name="form1" action="test.html" method="post" > <input type="text" name="username" value="国庆六十周年_1" id="tid" onchange="" > <input type="button" name="ok" value="保存1" /> </form> </body> <script type="text/javascript"> //输出<input type="text" name="username" value="国庆六十周年_1" id="tid">标签value属性的值 var inputElement=document.getElementById("tid"); alert(inputElement.value); //输出<input type="text" name="username" value="国庆六十周年_1" id="tid">标签type属性的值 alert(inputElement.type); </script> </html>
</pre><pre name="code" class="html">
就是很简单的得到相应的标签!!!
大家随意看一看就可以了