How do I create HTML table using jQuery dynamically?

后端 未结 5 2072
梦如初夏
梦如初夏 2020-12-08 20:10

I am trying to create a HTML table like the following dynamically using jQuery:



        
      
      
      
5条回答
  •  猫巷女王i
    2020-12-08 20:12

    An example with a little less stringified html:

    var container = $('#my-container'),
      table = $('
'); users.forEach(function(user) { var tr = $(''); ['ID', 'Name', 'Address'].forEach(function(attr) { tr.append(''); }); table.append(tr); }); container.append(table);

提交回复
热议问题
' + user[attr] + '