Computer >> 컴퓨터 >  >> 프로그램 작성 >> JavaScript

JavaScript로 목록 항목 마커 유형을 설정하는 방법은 무엇입니까?


목록 항목 마커 유형의 유형을 설정하려면 listStyleType 재산. 마커 유형은 정사각형, 원형, dic 등일 수 있습니다.

예시

다음 코드를 실행하여 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>