Codelab Editor
Free Online HTML Editor
Run
Learn jQuery
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>jQuery Add - prepend() Method</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <style> body { font-family: Arial, sans-serif; padding: 30px; background: #f9f9f9; } h2 { color: #222; } button { margin-top: 20px; padding: 10px 20px; background: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; } ul { margin-top: 20px; padding-left: 20px; } li { margin-bottom: 8px; color: #333; } </style> </head> <body> <!--==============================H2 Heading==============================--> <h2>jQuery Add – prpend() Method</h2> <p>The <code>prepend()</code> method is used to add content at the start of the selected elements. It’s great for dynamically adding HTML or text.</p> <button id="addItem">Add Item</button> <ul id="list"> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul> <script> $(function(){ $("#addItem").on("click", function(){ $("#list").prepend("<li>New list item</li>"); }); }); </script> </body> </html>
Editor Commands
Ctrl
F
Find
Ctrl
G
Find Next
Ctrl
⇧
G
Find Previous
Ctrl
⇧
F
Find & Replace
Ctrl
]
Indent Code Right
Ctrl
[
Indent Code Left
⇧
Tab
Auto Indent Code
Ctrl
/
Line Comment
Ctrl
Alt
/
Block Comment
TutsInsider Actions
Alt
S
Run Code
Ctrl
C
Copy Editor Code
Ctrl
A
Select All Editor Code
Ctrl
S
Save/Download
Ctrl
Alt
X
Rotate
Ctrl
Alt
T
Switch Theme
Ctrl
⇧
C
Open Console
Esc
Close Console