How do you append rows to a table using jQuery?

前端 未结 7 1364
渐次进展
渐次进展 2020-12-01 01:34

Hi I was trying to add a row to a table using jQuery, but it is not working.
What might be the reason?

And, can I put in some value to the newly added row..?

7条回答
  •  攒了一身酷
    2020-12-01 01:48

    I always use this code below for more readable

    $('table').append([
    '',
        'My Item 1',
        'My Item 2',
        'My Item 3',
        'My Item 4',
    ''
    ].join(''));
    

    or if it have tbody

    $('table').find('tbody').append([
    '',
        'My Item 1',
        'My Item 2',
        'My Item 3',
        'My Item 4',
    ''
    ].join(''));
    

提交回复
热议问题