type瀏覽器中用於出入的控件(比方說type=text,這就是一個文本框;type=button,這就是一個按鈕)
type可選的值如下:
button 按鈕
checkbox 複選按鈕組件
file 文件上傳組件
hidden 隱藏域
image 圖片區域
password 密碼輸入文本框
radio 單選按鈕組件
reset 重置表單按鈕
submit 提交表單按鈕
text 文本輸入框
***********************************************************************
id是唯一標識符,不允許有重複值(類似數據表的主鍵,pk),可以通過它的值來獲得對應的html標籤對象。 (如果在同一頁面代碼中,出現重複的id,會導致不可預料的錯誤)
js代碼:document.getElementById(id_value)
根據指定的id獲得它的對象引用
***********************************************************************
name和id的功能是一樣的,同樣用來標識html標籤,但唯一不同的是name允許有重複的值。
js代碼:document.forms[0].name或document.getElementsByName(name)
根據指定的name獲得它的對象引用數組
***********************************************************************
value代表某個html標籤的值
打個比方:<input type=text name=seq value=hello! id=seq007 />
你將看到網頁中文本框的內容為hello!
///////////////////////////////////////////////////////////////////////
<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd>
<html>
<head>
<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 />
<title>Untitled Document</title>
<script>
</script>
</head>
<body>
<form>
<input type=text name=seq value= id=seq001 />
<input type=text name=seq value= id=seq002 />
<input type=text name=seq value= id=seq003 />
</form>
</body>
</html>
///////////////////////////////////////////////////////////////////////
document.getElementById(seq001)獲得的是id=seq001的這個對象標籤的引用
document.forms[0].seq
將返回網頁中第一個表單裡面所有name=seq的標籤對象引用數組
document.getElementsByName(seq)
將返回網頁中所有name=seq的標籤對象引用數組