How to perform multiple actions on the same element using jquery
-
26-10-2019 - |
Question
how do I include both drag and resize on a single element.
<head>
<style type="text/css">
#header { width: 200px; height: 100px; background: blue; }
</style>
<script>
$(document).ready(function() {
$("#header").draggable().resizable();
});
</script>
</head>
<body style="font-size:100%;font-weight:bold;font-style:times" >
<div id="header">
<label> Header <input type="text" value="headerBox" /> </label>
<input type="button" value="submit" id="headerSubmit" name="submit" />
<input type="reset" value="reset"/>
</div>
</body>
</html>
Solution
both draggable and resizable supports chaining mode so you can simplify your code in one line
$(document).ready(function() {
$("#header").draggable().resizable();
});
see demo here.... DEMO
refer this tutorial for more information .....Draggable and resizable
OTHER TIPS
$(document).ready(function() {
$("#header").draggable();
$("#header").resizable();
});
see if it works
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow