Codelab Editor
Free Online HTML Editor
Run
Learn jQuery
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>jQuery Animate Width Example</title> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <style> body { font-family: Arial, sans-serif; background: #f4f6f8; padding: 40px; text-align: center; } h2 { color: #333; } p.description { color: #555; font-size: 15px; max-width: 500px; margin: 0 auto 20px; } #myBox { width: 100px; height: 50px; background-color: #3498db; margin: 20px auto; border-radius: 4px; transition: background-color 0.3s; } #myBox:hover { background-color: #2980b9; } #animateBtn { padding: 10px 20px; font-size: 16px; background: #2c3e50; color: white; border: none; border-radius: 4px; cursor: pointer; } #animateBtn:hover { background: #3e5871; } </style> </head> <body> <h2>Animate Width Example</h2> <p class="description"> Click the button below to smoothly expand the blue box's width from 100px to 300px over 500 milliseconds. </p> <div id="myBox"></div> <button id="animateBtn">Animate Width</button> <script> $(document).ready(function(){ $('#animateBtn').click(function(){ $('#myBox').animate( { width: '300px' }, 500, function() { console.log('Width animation completed.'); } ); }); }); </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