getElementById=由識別元(ById)取得(get)元件(Element)
包含的HTML內容 | document.getElementById('ID').innerHTML |
使用樣式 | document.getElementById('ID').className |
顏色 | document.getElementById('ID').style.color |
背景色 | document.getElementById('ID').style.backgroundColor |
背景影像 | document.getElementById('ID').style.backgroundImage |
顯示? | document.getElementById('ID').style.visibility |
取得或設定表單物件值
文字欄位
HTML語法 | <input type="text" name="textName"> |
值 | document.formName.textName.value |
值的長度 | document.formName.textName.value.length |
是否唯讀 | document.formName.textName.readOnly |
文字區塊
HTML語法 | <textarea name="textareaName" cols="32" rows="6"></textarea> |
值 | document.formName.textareaName.value |
值的長度 | document.formName.textareaName.value.length |
是否唯讀 | document.formName.textareaName.readOnly |
寬度 | document.formName.textareaName.cols |
高度 | document.formName.textareaName.rows |
單選核取
HTML語法 | <input type="radio" name="radioName" value="1"> |
共幾項 | document.formName.radioName.length |
第N項的值 | document.formName.radioName[N].value |
第N項核取? | document.formName.radioName[N].checked |
只有一項的值 | document.formName.radioName.text |
只有一項核取? | document.formName.radioName.checked |
多選核取 (N由0開始計算)
HTML語法 | <input type="checkbox" name="boxName" value="1"> |
共幾項 | document.formName.boxName.length |
第N項的值 | document.formName.boxName[N].value |
第N項核取? | document.formName.boxme[N].checked |
只有一項的值 | document.formName.boxName.text |
只有一項核取? | document.formName.boxe.checked |
下拉清單 (N由0開始計算)
HTML語法 | <select name="selectName"> <option value="value">text </select> |
共幾項 | document.formName.selectName.length |
選到第N項 | document.formName.selectName.selectedIndex |
第N項的值 | document.formName.selectName.options[N].value |
第N項的文字 | document.formName.selectName.options[N].text |
按鈕
HTML語法 | <input type="submit" name="btnName"> <input type="button="btnName"> <input type="reset" name="btnName"> |
按鈕上的字 | document.formName.btnName.value |
按鈕可不可按 | document.formName.btnName.disabled |
沒有留言:
張貼留言