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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:31:35+00:00 2026-06-15T17:31:35+00:00

I am trying to create a dynamic table using JQuery. Right now, I want

  • 0

I am trying to create a dynamic table using JQuery.

Right now, I want each cell to be a div
but I am not sure how I should go about doing it.

My ultimate goal is wanting each element to be draggable and changing them to be a div seems like a good idea.

Please do suggest any possible ways of doing it or how I could go about changing each cell to be a div so I could make it draggable.

This are the relevant codes.

//create table function
function createDynamicTable(tbody, rows, cols) {
if(tbody == null || tbody.length < 1) return;
for(var r=1; r<=rows; r++){
  var trow=$("<tr>");
  for(var c=1; c<=cols; c++){
//first column data
    if (c==1){

        if(r==1){
      $("<td>")
        .addClass("tableCell")
        .text("Subject")
        .data("col", c)
        .appendTo(trow);
    }


        if(r==2){
      $("<td>")
        .addClass("tableCell")
        .text("Monday")
        .data("col", c)
        .appendTo(trow);
    }

        if(r==3){
      $("<td>")
        .addClass("tableCell")
        .text("Tuesday")
        .data("col", c)
        .appendTo(trow);
    }


        if(r==4){
      $("<td>")
        .addClass("tableCell")
        .text("Wednesday")
        .data("col", c)
        .appendTo(trow);
    }


        if(r==5){
      $("<td>")
        .addClass("tableCell")
        .text("Thursday")
        .data("col", c)
        .appendTo(trow);
    }


        if(r==6){
      $("<td>")
        .addClass("tableCell")
        .text("Friday")
        .data("col", c)
        .appendTo(trow);
    }   

        if(r==7){
      $("<td>")
        .addClass("tableCell")
        .text("Saturday")
        .data("col", c)
        .appendTo(trow);
    }


        if(r==8){
      $("<td>")
        .addClass("tableCell")
        .text("Sunday")
        .data("col", c)
        .appendTo(trow);
    }
    }
    else{

   //for first row
    if(r==1){
        if(c==2){
        $("<td>")
            .addClass("tableCell")
            .text("101")
            .data("col", c)
            .appendTo(trow);
        }
        if(c==3){
        $("<td>")
            .addClass("tableCell")
            .text("102")
            .data("col", c)
            .appendTo(trow);
        }

        if(c==4){
        $("<td>")
            .addClass("tableCell")
            .text("103")
            .data("col", c)
            .appendTo(trow);
        }
        if(c==5){
        $("<td>")
            .addClass("tableCell")
            .text("104")
            .data("col", c)
            .appendTo(trow);
        }
        if(c==6){
        $("<td>")
            .addClass("tableCell")
            .text("105")
            .data("col", c)
            .appendTo(trow);
        }
    }
    else{
            var cellText = "Cell " + r + "." + c
            $("<td>")
            .addClass("tableCell")
            .text(cellText)
            .data("col", c)
            .appendTo(trow);

    }
}
  }
  trow.appendTo(tbody);
  } 
}
  • 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-15T17:31:36+00:00Added an answer on June 15, 2026 at 5:31 pm

    Just to answer this.
    I did the following to add a div into the table.

     var tcol=$("<td>")
            $("<div>")
                .addClass("Div1")
                .text("Div works")
                .appendTo(tcol);
    
                $(tcol)
                .addClass("TableCell")
                //.text("101")
                .data("Col",c)
                .appendTo(trow);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a dynamic table using php but needed to get
I am trying to create a dynamic table with each row containing two date
I am trying to create dynamic html table but the problem is that it
I am trying to create dynamic menus from the database using the following example
I am trying to create a dynamic 'page' listing for threads/comments using AJAX. in
I'm trying to create a dynamic grid using ExtJS. The grid is built and
I am trying to create dynamic excel sheet, with the help of php using
I am trying to create a completely dynamic way to query entity framework using
I need some help. I want to create a dynamic line chart using Google's
I am trying to create a dynamic UI using UpdatePanel of AJAX toolkit. Let

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.