jQuery split a table into two tables at a particular row number

后端 未结 2 1289
广开言路
广开言路 2021-01-06 06:04

I need to split a table into two tables at a particular row number using jQuery. Can this be done?

I googled but couldn\'t find anything. jQuery\'s pretty powerful,

2条回答
  •  梦谈多话
    2021-01-06 06:27

    jQuery Slice method will be useful in such case: documentation here

    Add a table with some rows in html:

    Row 1 Dummy Data
    Row 2 Dummy Data
    Row 3 Dummy Data
    Row 4 Dummy Data
    Row 5 Dummy Data
    Row 6 Dummy Data
    Row 7 Dummy Data
    Row 8 Dummy Data
    Row 9 Dummy Data
    Row 10 Dummy Data

    Slice n rows using jQuery, create new table instance and append rows:

    
    

    See working demo here

提交回复
热议问题