Try It Editor
Tip: Press
Ctrl/⌘ + Enter
to Run
▶ Run
Reset
Copy
Download
Code
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Resizable Events</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <link rel="stylesheet" href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css"> <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.min.js"></script> <style> #box{width:200px;height:120px;padding:10px;background:#e8f4ff;border:1px solid #7cb9e8;} #log{margin-top:10px;font-family:monospace;background:#f5f5f5;border:1px solid #ddd;padding:8px;} </style> </head> <body> <div id="box" class="ui-widget-content"> <p>Resize me and watch the log below.</p> </div> <div id="log">No events yet.</div> <script> $(function(){ $("#box").resizable({ start: function(e, ui){ $("#log").text("start: width " + ui.size.width + ", height " + ui.size.height); }, resize: function(e, ui){ $("#log").text("resize: width " + Math.round(ui.size.width) + ", height " + Math.round(ui.size.height)); }, stop: function(e, ui){ $("#log").text("stop: width " + Math.round(ui.size.width) + ", height " + Math.round(ui.size.height)); } }); }); </script> </body> </html>
Output