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

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -