Computer >> Computer tutorials >  >> Programming >> Javascript

How to set an image as the list-item marker with JavaScript?


To set an image as the marker in list-item, use the listStyleImage property in JavaScript.

Example

You can try to run the following code to set an image as the list-item marker with JavaScript −

<!DOCTYPE html>
<html>
   <body>
      <ol id="myID">
         <li>One</li>
         <li>Two</li>
      </ol>
      <button type="button" onclick="display()">Update list image</button>
      <script>
         function display() {
            document.getElementById("myID").style.listStyleImage = "url('https://tutorialspoint.com/css/images/bullet.gif')";
         }
      </script>
   </body>
</html>