Form 對象
Form 對象方法
reset() :把表單的所有輸入元素重置為它們的默認值。
submit() :提交表單。
Text 對象
Text 對象屬性
disabled :設置或返回文本域是否應被禁用。
readOnly :設置或返回文本域是否應是只讀的。
value :設置或返回文本域的 value 屬性的值。
Text 對象方法
focus() :在文本域上設置焦點。
示例
!DOCTYPE html html head meta charset= UTF-8 title /title /head body form input name = wd / input type= submit value= 百度一下 quot;sub() /form script var form = document.getElementsByTagName( form )[0]; var text = document.getElementsByName( wd )[0]; text.focus(); function sub(){ var text = document.getElementsByName( wd )[0];// text.value = 魔道 // text.readOnly = true // console.log(text.readOnly);// text.disabled = true console.log(text.disabled); text.focus(); //type為text、password、textarea的標簽均有value、focus、disabled、readOnly /script /body /html Radio 對象
Radio 對象屬性
checked :設置或返回單選按鈕的狀態。
disabled :設置或返回是否禁用單選按鈕。
value :設置或返回單選按鈕的 value 屬性的值。
Checkbox 對象
Checkbox 對象屬性
checked :設置或返回 checkbox 是否應被選中。
disabled :設置或返回 checkbox 是否應被禁用。
value :設置或返回 checkbox 的 value 屬性的值
Select 對象
Select 對象集合
options[] :返回包含下拉列表中的所有選項的一個數組。
Select 對象屬性
disabled :設置或返回是否應禁用下拉列表。
length :返回下拉列表中的選項數目。
selectedIndex :設置或返回下拉列表中被選項目的索引號。
Select 對象方法
add() :向下拉列表添加一個選項。
remove() :從下拉列表中刪除一個選項。
Option 對象
Option 對象構造方法
Option(text,value) :通過text和value值創建Option對象
Option 對象屬性
selected :設置或返回 selected 屬性的值。
text :設置或返回某個選項的純文本值。
value :設置或返回被送往服務器的值。
Select對象及Option對象示例
!DOCTYPE html html head meta charset= UTF-8 title /title /head body select id= grade option value= 1 一年級 /option option value= 2 二年級 /option option value= 3 三年級 /option option value= 4 四年級 /option /select input type= button quot;text() value= 按鈕 / script type= text/javascript function text(){ var select = document.getElementById( grade console.log(select.disabled); console.log(select.length); console.log(select.selectedIndex); console.log( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~` ) var options = select.options; console.log(options[select.selectedIndex].value); console.log( @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ) for(var i=0;i options.length;i++){ console.log(options[i].value); console.log(options[i].selected); console.log(options[i].text); var option = new Option( 五年級 , 5 select.add(option); select.remove(0); /script /body /html !DOCTYPE html html head meta charset= UTF-8 title /title /head body span >Image 對象
Image 對象屬性
src:設置或返回圖像的 URL。
相關推薦:
以上就是HTML對象:html一些對象屬性的介紹的詳細內容,html教程
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。
新聞熱點
疑難解答