javascript - Dynamically added DIV with both dragging and resizing capabilities -
var total = 0; function add() { total++; document.body.innerhtml = document.body.innerhtml + '<div id="'+total+'" class="drag"></div>'; $('.drag').draggable().resizable(); } add(); add(); add();
http://jsfiddle.net/zvzfq/631/
the script revised works (sorta) problem last div class .drag
dynamically added body
element using javascript function add()
replaces sizable()
functionality of other divs class .drag
not reason, draggabble()
functionality
this works:
var t = 0; function add() { $('body').append('<div id="d'+t+'" class="drag"></div>'); $('#d'+t).draggable().resizable(); t++; }
here's jsfiddle: http://jsfiddle.net/zvzfq/634/
Comments
Post a Comment