JQuery List items for Prepend

 

In this example, prepend() method is used to Inserts List items at the start of the selected elements. Here we have used HTML <ol> tags to display the selected list. We can take an infinite number of new elements as parameters.

 
 
 
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("ol").prepend("<li>Prepended Items</li>"); }); }); </script> </head> <body> <ol> <li>List1</li> <li>List2</li> <li>List3</li> </ol> <button>Prepend List Items</button> </body> </html>
Output