How to set the position of the list-item marker with JavaScript?

JavascriptWeb DevelopmentFront End Scripts

To set the position of the marker of the list-item, use the listStylePosition property. You can try to run the following code to set the position of the list-item marker with JavaScript −

Example

Live Demo

<!DOCTYPE html>
<html>
   <body>
      <ol id="myID">
         <li>One</li>
         <li>Two</li>
      </ol>
      <button type="button" onclick="displayInside()">Add list inside</button>
      <button type="button" onclick="displayOutside()">Add list outside</button>
      <script>
         function displayInside() {
            document.getElementById("myID").style.listStylePosition = "inside";
         }
         function displayOutside() {
            document.getElementById("myID").style.listStylePosition = "outside";
         }
      </script>
   </body>
</html>
raja
Published on 27-Feb-2018 17:55:28
Advertisements