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 −

Live Demo

<!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('http://tutorialspoint.com/css/images/bullet.gif')";
         }
      </script>
   </body>
</html>

Monica Mona
Monica Mona

Student of life, and a lifelong learner

Updated on: 23-Jun-2020

114 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements