Li value 屬性返回/設置 <li> 元素的 value 屬性的值。
用法
以下是語法 -
- <li> 的返回值value 屬性
liObject.value
- 價值<li>屬性值集
liObject.value = ‘string’
讓我們看一個例子Li value屬性 -
示例
<!DOCTYPE html>
<html>
<head>
<title>HTML DOM value</title>
<style>
form {
width:70%;
margin:0 auto;
text-align:center;
}
* {
padding:2px;
margin:5px;
}
input[type="button"] {
border-radius:10px;
}
ol{
width:30%;
margin:0 auto;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>HTML-DOM-value</legend>
<h3>Race Result</h3>
<ol id="race">
<li>Alex</li>
<li>Eden</li>
<li>Samuel</li>
<li>Zampa</li>
</ol>
<input type="button" onclick="rectifyResult()" value="Alex Cheated">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var studentList = document.getElementsByTagName("li");
var race = document.getElementById("race");
function rectifyResult() {
studentList[1].value = '1';
studentList[2].value = '2';
studentList[3].value = '3';
race.removeChild(studentList[0])
divDisplay.textContent = 'Alex is disqualified';
}
</script>
</body>
</html>
輸出
這將產生以下輸出 -
點擊前‘Alex Cheated’按鈕 -
檢查後‘What exams are in this week?’按鈕 -
相關用法
- HTML DOM li用法及代碼示例
- HTML DOM Style overflowY屬性用法及代碼示例
- HTML DOM Document hidden屬性用法及代碼示例
- HTML DOM IFrame用法及代碼示例
- HTML DOM Textarea cols屬性用法及代碼示例
- HTML DOM Style pageBreakAfter屬性用法及代碼示例
- HTML DOM Base href屬性用法及代碼示例
- HTML DOM Pre用法及代碼示例
- HTML DOM Input Month用法及代碼示例
- HTML DOM Video canPlayType()用法及代碼示例
- HTML DOM Range deleteContents()用法及代碼示例
- HTML DOM console.dirxml()用法及代碼示例
- HTML DOM Style transition屬性用法及代碼示例
- HTML DOM Video volume屬性用法及代碼示例
- HTML DOM Input Range用法及代碼示例
- HTML DOM Style outlineOffset屬性用法及代碼示例
- HTML DOM Storage setItem()用法及代碼示例
- HTML DOM TableHeader用法及代碼示例
- HTML DOM Style maxWidth屬性用法及代碼示例
- HTML DOM NodeIterator whatToShow屬性用法及代碼示例
注:本文由純淨天空篩選整理自AmitDiwan大神的英文原創作品 HTML DOM li value Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。