jQuery select visual column in table with rowspan

前端 未结 5 1134
迷失自我
迷失自我 2021-01-02 11:58

I have seen a few similar questions but nothing that answers this specific problem. Consider the following table:

5条回答
  •  Happy的楠姐
    2021-01-02 12:23

    If you want to support colspan and rowspan, then first you need to build table index, ie. matrix that identifies cell position in every row regardless of the markup. Then you need to track events of all the table cells and calculate their offset in the matrix and the columns that share the horizontal and vertical index.

    This is the description of https://github.com/gajus/wholly, a plugin that I have developed for this purpose. Using the events you can find all the values in the row or in a col, including those attached using rowspan or solspan properties.

    I made a visualisation illustrating a table and the events that are triggered upon navigation.

    Wholly

    Orange is the active cell, red are the cells triggered by the vertical event and blue are the cells triggered by the horizontal event.

提交回复
热议问题