Codelab Editor
Free Online HTML Editor
Run
Learn jQuery
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>jQuery Animate With Duration</title> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <style> body { font-family: Arial, sans-serif; background: #f4f6f9; margin: 0; padding: 50px; display: flex; flex-direction: column; align-items: center; } h2 { color: #2c3e50; margin-bottom: 10px; } p.description { color: #555; margin-bottom: 30px; max-width: 500px; text-align: center; font-size: 15px; } #notification { position: relative; width: 300px; height: 0; background-color: #3498db; color: white; padding: 0 15px; border-radius: 4px; box-shadow: 0 3px 8px rgba(0,0,0,0.2); opacity: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; } #notification p { margin: 0; font-size: 14px; line-height: 50px; } #triggerBtn { margin-top: 30px; padding: 10px 20px; font-size: 16px; background-color: #333; color: white; border: none; border-radius: 5px; cursor: pointer; } #triggerBtn:hover { background-color: #555; } </style> </head> <body> <h2>jQuery Animate With Duration</h2> <p class="description"> This example demonstrates how to use jQuery's <code>.animate()</code> method with duration settings to smoothly show and hide a notification banner. </p> <div id="notification"> <p>This is a notification banner.</p> </div> <button id="triggerBtn">Trigger Animation</button> <script> $(document).ready(function() { $('#triggerBtn').click(function() { var $notification = $('#notification'); // Reset to hidden and collapsed $notification.css({ top: '0px', opacity: 0, height: '0px' }); // Animate in $notification .animate({ top: '0px', opacity: 1, height: '50px' }, 600) .delay(1000) .animate({ height: '0px', opacity: 0 }, 400); }); }); </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