Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i make element both draggable and resizable in jquery?

Tags:

jquery

How can i make element both draggable and resizable in jquery?

like image 550
Vinay Gayakwad Avatar asked Jan 28 '11 06:01

Vinay Gayakwad


3 Answers

both draggable and resizable supports chaining mode so you can simplify your code in one line.
Let say you have a div and id of that div is header which you want to make draggable and resizable.then jquery will work like this....

$(document).ready(function() {

    $("#header").draggable().resizable();
 });

see demo here...DEMO
refer this tutorial for more information ....Draggable and resizable

like image 185
Vivek Avatar answered Nov 11 '22 21:11

Vivek


Besides using jQuery you also have to use jQuery UI http://jqueryui.com/demos/.

jQuery UI will provide all of the functionality for what you would need. More specifically you want the Draggable and Resizable plugins (perhaps the Droppable too depending of what you are trying to do).

Then you will need to do the following to make it Draggable and Resizable:

$(document).ready(function() {

    $(".elements").draggable().resizable();
 });
like image 4
Carlos Avatar answered Nov 11 '22 20:11

Carlos


this is the original source

// this will make <div id="box"> resizable and draggable 
$('#box').resizable().parent().draggable(); 

// same but slightly safer since it checks parent's class 
$('#box').resizable().parent('.ui-wrapper').draggable(); 
like image 3
user1660624 Avatar answered Nov 11 '22 21:11

user1660624