Codelab Editor
Free Online HTML Editor
Run
Learn jQuery
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>jQuery Animate with Basic Easing</title> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <style> body { font-family: Arial, sans-serif; background: #f3f6fa; padding: 40px; display: flex; flex-direction: column; align-items: center; } h2 { color: #34495e; margin-bottom: 10px; } p.description { max-width: 600px; color: #555; text-align: center; margin-bottom: 20px; font-size: 15px; } .menu { position: relative; width: 200px; height: 100px; background: #3498db; color: #fff; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 16px; margin-bottom: 30px; box-shadow: 0 4px 8px rgba(0,0,0,0.2); } .controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; max-width: 400px; width: 100%; } .controls button { padding: 10px; font-size: 14px; border: none; border-radius: 4px; cursor: pointer; background: #2c3e50; color: #fff; width: 100%; } .controls button:hover { background: #3e5871; } </style> </head> <body> <h2>jQuery Animate with Easing</h2> <p class="description"> This example shows how jQuery's built-in <code>linear</code> and <code>swing</code> easing options affect animation timing. </p> <div id="menu" class="menu">Menu Box</div> <div class="controls"> <button id="linear">Slide In (Linear)</button> <button id="swing">Slide In (Swing)</button> <button id="fadeOut">Fade Out</button> <button id="reset">Reset</button> </div> <script> $(document).ready(function(){ const $menu = $('#menu'); $menu.css({ left: '-220px', opacity: 1 }).show(); $('#linear').click(function(){ $menu.stop(true).css({ left: '-220px', opacity: 1, display: 'flex' }).animate({ left: '0px' }, 700, 'linear'); }); $('#swing').click(function(){ $menu.stop(true).css({ left: '-220px', opacity: 1, display: 'flex' }).animate({ left: '0px' }, 700, 'swing'); }); $('#fadeOut').click(function(){ $menu.stop(true).animate({ opacity: 0 }, 800, 'swing'); }); $('#reset').click(function(){ $menu.stop(true).css({ left: '-220px', opacity: 1 }).show(); }); }); </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