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 7895831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:44:18+00:00 2026-06-03T07:44:18+00:00

I am just starting to learn jQuery and have gotten some of the basic

  • 0

I am just starting to learn jQuery and have gotten some of the basic layout and UI plugins to work. However, I would like to create a custom widget that, using syntax that looks something like this:

var objs = [
            {name: 'obj1', prop1: 'val1', prop2: 'val2'},
            {name: 'obj2', prop1: 'val3', prop2: 'val4'},
            {name: 'obj3', prop1: 'val5', prop2: 'val6'},
           ];

$(document).ready(function(){
  myList = $('#divlist').mywidget(objs);
});

Where this code creates a list of draggable objects within the div named “divlist”. The issue is here that the html/formatting that comprises the list items would need to be generated by the widget and dynamically added to the parent container, because they would not exist in the html beforehand.

All the jQuery tutorials I’ve seen operate on pre-existing html and just reformat/move/style it. Anyone have ideas about how I could do this?

  • 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-03T07:44:19+00:00Added an answer on June 3, 2026 at 7:44 am

    I take it you want to know how to create new elements (like div or spans or tables) on the fly in JavaScript/jQuery? If so, there are a few ways.

    Create it with the document object.

    var my_new_element = document.createElement("div");
    // Then feed it to jQuery so you can work with it.
    $(my_new_element);
    

    Or create it with jQuery.

    var my_new_element = $('<div>');
    

    For your solution, you’ll need to loop over the array of JSON objects and create each div, adding them to your parent container as you go. Example:

    var parent_div = '#divlist';
    for (var i = 0; i < objs.length; i++) {
      // Feed it straight to jQuery so it's easier to work with.
      var widget_member = $(document.createElement('div'));
    
      // Make it draggable.
      widget_member.draggable();
    
      // Append to the parent div.
      $(parent_div).append(widget_member);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just starting to learn Xcode, and have run in to some problems... I've
I am just starting to learn Python, but I have already run into some
Just starting to learn some basic C and messing around with the stat() system
I'm just starting to learn AspectJ, and I have use-case for say, User login.
I am just starting to learn php, how would I initiate a echo statement
I'm just starting to learn T-SQL and could use some help in understanding what's
I'm just starting to learn about jQuery. I'm more of a html+css web designer
I'm just starting to learn about jQuery and am becoming familiar with how jQuery
I'm just starting to learn JavaScript, and stumbled over Underscore.js and jQuery . Underscore
I am just starting to learn JNI. I have been following a simple example,

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.