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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:21:49+00:00 2026-06-06T08:21:49+00:00

I create one table by using jquery : <div class=productlist style=float:left; id=productlist> <script type=text/javascript

  • 0

I create one table by using jquery :

 <div class="productlist" style="float:left;" id="productlist">
 <script type="text/javascript" language="javascript">
    function loadMore() {
       var $parent = $("#productlist").empty();
       $parent.append('<table id="myTable" cellpadding="0" cellspacing="0" width="100%" class="productlist" style="margin-left:4px; padding-top:2px;"><tbody>');
       var $table = $parent.find("#myTable > tbody");
       var htmlRow = [
                     '<tr align="center">',
                     '<td align="center" id="colunm-product">',
                     '<br />',
                     '<div id="brand-item"><a href="#" class="brand_id"><img src="' + value.BrandImage + '" width = "85px"/></a></div>',
                     '<div id="product_image"><a href="'+'<%: Url.Content("~/") %>' +'Products/ProductSpec/' + value.ID +'?dep='+ value.DepartmentID +'&cat='+value.CategoryID+'&tab=2" style="text-decoration:none"><img src="' + value.PictureName + '" alt="Product" width="135px"/></a></div>',
                     '</td>',
                     '</tr>'
                      ];
      $table.append(htmlRow.join(''));
      $("#myTable > tbody").append('</tbody></table>');
   }
  </script>

And I call the function in document.ready. But the result is unexpected in my view:

 <table id="myTable" cellpadding="0" cellspacing="0" width="100%" class="productlist" style="margin-left:4px; padding-top:2px;">
    <tbody>
      <br/><br/>
      <tr> my data </tr>
    </tbody></table>

I don’t know why there are <br><br> in the table. How to avoid that problem?

Thanks.

  • 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-06T08:21:52+00:00Added an answer on June 6, 2026 at 8:21 am

    You are trying to insert into the DOM as if you are writing html in a text editor, and it’s the wrong approach. Any element you insert is a complete element and it is already “closed”. You can’t insert the beginning html of a table, add some rows and then add closing tags…as you would write it.

    WHen you insert an empty table as example with jQuery , there are several ways to write the tag:

     $('<table>') 
     $('<table/>')
     $('<table></table>') // skipping over tbody issues for now
    

    All 3 produce the same thing… a complete table DOM node. This table already has already been closed, as we think of it with html tags, and in the case of IE for certain, and possibly other browsers, it has a tbody as well. Think of it as the top and bottom of the html are in place.

    Now when we append internal elements, they also need to be complete.

    The table example was a single tag, inserting mulitple tags at one time require valid closed html as we knwow it in an editor.

    $(”) doesn’t work, in this case both tags need closing in proper order. Simiarly we don’t append a nummber of rows and then try to throw in closing tags for tbody and table as you have tried.

    I believe this should give you a better understanding on how to adjust your code so that it isn’t fragmented.

    Inserting fragmented code as you’ve tried will produce unwanted beahvior and even possible rejection

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

Sidebar

Related Questions

I have to create one table using XSLT and CSS. The table should look
I have created one table using the below command: create table Table1( Id int
I'm trying to create a copy/paste system for a HTML table using jQuery and
Using the jQuery library, not any other JavaScript library, if you were to create
I have a huge table from one mysql db, I want to create a
I'm trying to create a table with Listview and one of the fields I'm
I am attempting to create a table that will only display one row at
If I create a simple .html file with a table inside it. Within one
Basically I want to create one large object of many object in JavaScript. Something
I am using jquery to place an overlay over a div while I am

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.