Codelab Editor
Free Online HTML Editor
Run
Learn jQuery
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>jQuery Move With prepend() Method (Callback Example)</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; } #container { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; } .box { width: 80px; height: 80px; background: #FF5722; color: white; display: flex; align-items: center; justify-content: center; font-weight: bold; border-radius: 4px; transition: all 0.3s ease; } button { padding: 10px 20px; background: #007BFF; color: white; border: none; border-radius: 4px; cursor: pointer; } </style> </head> <body> <h2>jQuery Move With prepend() Method</h2> <p>The <code>prepend()</code> method moves or inserts content at the beginning of the selected element. This example also uses a callback to visually update the moved item.</p> <div id="container"> <div class="box">A</div> <div class="box">B</div> <div class="box">C</div> <div class="box" style="background: blue;">D</div> </div> <button id="moveLastToStart">Move Last Box to Start</button> <script> $(document).ready(function(){ $("#moveLastToStart").click(function(){ const lastBox = $(".box:last"); $("#container").prepend(function() { lastBox.css("background", "#4CAF50").text("Moved"); return lastBox; }); }); }); </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