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

  • Home
  • SEARCH
  • 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 7848103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:05:04+00:00 2026-06-02T18:05:04+00:00

In my project im creating dynamically divs with jquery everytime you click a button.

  • 0

In my project im creating dynamically divs with jquery everytime you click a button. Now i want these new divs to have draggable and resizable properties. Here is what ive done so far:

$("#button1").click(function(){
     $("<div/>", {
       "id": "test",
        text: "",
      }).appendTo("body");
     $( "#test" ).resizable();
     $( "#test" ).draggable();
  });

This code works somehow, the problem is that only the first div that was created is resizable and draggable.
Also is it possible to put another button in order to delete these new created divs?

  • 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-06-02T18:05:05+00:00Added an answer on June 2, 2026 at 6:05 pm

    id must be unique! you create multiple divs with the same test id => INVALID HTML

    Another thing, you don’t need to query the DOM, you can use the reference you got to make the created <div> resizable and draggable:

    $("#button1").click(function(){
         $("<div/>", {
           "class": "test",
            text: "",
          }).resizable().draggable()
          .appendTo("body");
      });
    

    If you want to use id for some reason:

    var counter = 1;
    
    $("#button1").click(function(){
         $("<div/>", {
           "class": "test" + (counter++),
            text: "",
          }).resizable().draggable()
          .appendTo("body");
      });
    

    #id selector comment in the docs site:

    Each id value must be used only once within a document. If more than one element has been assigned the same ID, queries that use that ID will only select the first matched element in the DOM. This behavior should not be relied on, however; a document with more than one element using the same ID is invalid.

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

Sidebar

Related Questions

I have a problem with my project . I am creating link buttons dynamically
i've stuck with problem. I have an ASP.NET project with dynamically creating controls. Even
I have been busy in my project creating a webapp (in struts) that manages
I'm creating a project from the book Sanderson Pro ASp.net mvc3. But I have
When I'm creating new project with GWT plug in it creates a skeleton project
When creating a new project in netbeans, if i select JAVA Desktop application, it
I am having a php project in which I am basically dynamically creating hyperlinks
I have an iPad project I'm working on that dynamically creates a number of
I have a best practices/performance question. I am creating an ASP.NET MVC 2 project,
Hi I'm doing a self-project on creating a jQuery UI to allow users to

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.