javascript的getElementById()的應用

<html>

<head>
<title>getElementById</title>
</head>
<body>
<form name="from1" action="text.html" method="post">
<input type="text" name="username" value="Id1" id="tid"/>
<input type="button" name="ok" value="baocun"/>
</form>
</body>
<script language="JavaScript">
//輸出<input type="text" name="username" value="Id1" id="tid"/>標籤的value的屬性
var inputElement=document.getElementById("tid");
alert(inputElement.value);
//輸出<input type="text" name="username" value="Id1" id="tid"/>標籤的type屬性的值
alert(inputElement.type);

</script>

</html>

注:id的屬性是唯一的




發佈了31 篇原創文章 · 獲贊 0 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章