I need help figuring out how to revert an element back to its original size after it has been modified with .resizable
. I attempted the following:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.13.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="https://code.jquery.com/ui/1.13.1/jquery-ui.js"></script>
<style>
.box {
border: 2px solid #008cba;
margin-top: 10px;
}
</style>
<script>
$(function() {
$('.box').resizable();
$('#btn').click(function() {
$('.box').resizable('destroy');
});
});
</script>
</head>
<body>
<button id='btn' type='button'>
Click-me
</button>
<div class='box'>
<h1 class='el1'>
Stack Overflow resizable
</h1>
</div>
</body>
</html>
Unfortunately, when I use $('.box').resizable('destroy');
, only the resize icon disappears. Is there a way to make the element return to its original size when the button is clicked using only jQuery
, without any additional JavaScript
code?