Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6988931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:08:47+00:00 2026-05-27T19:08:47+00:00

I am adding img tag dynamically in a container div. While creating img i

  • 0

I am adding img tag dynamically in a container div. While creating img i am adding 2 class draggable and resizable and then append to the container. So i am able to drag but unable to resize. What might be the issue?

Below is the code of creating img tag

var img = document.createElement('img');
$(img).attr("id", "dyndiv" + count);
$(img).attr("width", 40);
$(img).attr("height", 100);
$(img).attr("src", 'Uploads/' + window.frames['ifrm'].document.getElementById('dvFileName').innerHTML);

var $ctrl = $(img).addClass("draggable resizable ui-widget-content")
    .draggable({ 
        containment: '#containment-wrapper', 
        cursor: 'move', 
        snap: '#containment-wrapper' 
    })
    .resizable({
        aspectRatio:true,
        containment: '#containment-wrapper'
    });

objid = "dyndiv" + count;
count++;

$(img).css("margin-top", Math.ceil(140/2) + 'px');
$(img).css("margin-left", Math.ceil(60/2) + 'px');
$(img).css({
    'top':20,
    'left':30,
    'zindex':400 + count
});                                 
$("#containment-wrapper").append($ctrl);

This is the changed code as suggested by @Andrew Whitaker but still it is not working kindly help me with this..

          var $wrap_div = $("<div></div>", { 'id' : "dyndiv_img" + count }) ;
          $wrap_div.addClass("wrapper");
           $wrap_div.resizable({ containment: '#containment-wrapper'});

      var img_clip = document.createElement('img');

                                                                     $(img_clip).attr("id", "dyndiv" + count);
                                                                     $(img_clip).attr("src", current_clip ) ;                                                                         
                                                                     var $ctrl = $(img_clip).addClass("draggable ui-resizable ui-widget-content").draggable({ containment: '#containment-wrapper', cursor: 'move',delay: 200,distance: 30, opacity: 0.35}).wrap($wrap_div);
                                                                     objid = "dyndiv" + count ;
                                                                     count++;  

                                                                     $(img_clip).css({'top':20,'left':30});  
                                                                         //($ctrl).resizable({ containment: '#containment-wrapper'}) ;                                                                
                                                                     $("#containment-wrapper").append($ctrl);
                                                                     $('#' + objid).position({
                                                                     of: $( "#containment-wrapper" ),
                                                                     my: "center" + " " + "center",
                                                                     at: "center" + " " + "center"

                                                                    });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:08:47+00:00Added an answer on May 27, 2026 at 7:08 pm

    At last I found the method. No wrapper div is needed for resize and drag functionality for img tag.

                  $(img_tag).resizable().parent().draggable();
    

    This works for me.

    🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

pic_display+=<img src='+pic_url+' onClick='swapImage(+pic_url+);'> I am adding an image to the innerHTML of a div
I need to append a string (an img tag) to a tinyMCE editor instance.
Adding functionality to a class can be done by adding a method or by
When adding an EditItemTemplate of some complexity (mulitple fields in one template), and then
I have solved this with PHP by adding the 'time()' to the img src
Hi would like to add img source path dynamically as shown in the snippet
If I have this css div.myContainer img.noCampaign { display:none; } and this html/javascript <div
I am adding a custom view on main window then on the view i
I am creating some thumbnails dynamically with JQuery, like this (in a loop): var
<body> <div id=container> <div id=body> <center> <table width=650 border=0 cellspacing=0 cellpadding=5> <tbody> <tr> <td

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.