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

JavascriptWeb DevelopmentFront End Scripts

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>
raja
Published on 27-Feb-2018 13:21:37
Advertisements