Codelab Editor
Free Online HTML Editor
Run
Learn jQuery
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>jQuery Add – after() with Callback</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: #f4f4f4; } h2 { color: #222; } button { padding: 10px 20px; background: #007BFF; color: white; border: none; border-radius: 4px; cursor: pointer; margin-bottom: 20px; } .item { padding: 10px; background: #e0e0e0; margin-bottom: 10px; } .note { margin-top: 5px; padding: 8px; background: #ffc107; color: #000; border-radius: 4px; } </style> </head> <body> <h2>jQuery Add – after() Method with Callback</h2> <p>The <kbd>after()</kbd> method also supports a callback function, letting you generate dynamic content after each selected element.</p> <button id="addNote">Add Notes After Items</button> <div class="item">Item 1</div> <div class="item">Item 2</div> <div class="item">Item 3</div> <script> $(document).ready(function(){ $("#addNote").click(function(){ $(".item").after(function(index){ return "<div class='note'>Note after Item " + (index + 1) + "</div>"; }); }); }); </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