如何透過 JavaScript 設定列表項標記型別?
要設定列表項標記型別的型別,請使用 listStyleType 屬性。標記型別可以是方塊、圓形、字典等。
範例
你可以嘗試執行以下程式碼,透過 JavaScript 設定列表項標記型別 −
<!DOCTYPE html>
<html>
<body>
<ul id="myID">
<li>One</li>
<li>Two</li>
</ul>
<button type="button" onclick="displaySquare()">Update list style type (square)</button>
<button type="button" onclick="displayDecimal()">Update list style type (decimal)</button>
<script>
function displaySquare() {
document.getElementById("myID").style.listStyleType = "square";
}
function displayDecimal() {
document.getElementById("myID").style.listStyleType = "decimal";
}
</script>
</body>
</html>
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP