6.2 設定表單資料
text 一般文字框的設定值
<input type="text" class="the_text" id="the_text">var the_text = document.getElementById("the_text");
// 以下三種方式皆可
the_text.value = "測試"; // 這個較常見,但不會改變到標籤上的屬性
//the_text.setAttribute("value", "測試二");
//the_text.defaultValue = "測試三"; // 極少見textarea 多行文字框設定值
select 下拉選單的設定值
checkbox 的勾選
判斷有無勾選
設定勾選或不勾選
radio 單選框的選取
判斷有無選取
設定某項選取
Last updated