jQuery highlighting selected columns only in a table

后端 未结 6 1106
长发绾君心
长发绾君心 2021-01-02 19:46

I see this post on highlighting even columns but can I highlight only selected columns?

Here is the code they use:

$(\"table.Table22 > tbody >          


        
6条回答
  •  孤独总比滥情好
    2021-01-02 20:24

    have you concidered using colgroups instead of adding classes to every cell?

    i only recently started to see the power of colgroups myself, and they work like this:

    .highlight {
        background-color: yellow; 
     }
         
    header1 header2 header3 header4 header5
    cell a cell b cell c cell d cell e

    this would render a table with 5 columns, where 1 column has css class to highlight the first col. so actually the only thing you have to do then, add a function to the hover of each cell, to just add the highlighting class to the corresponding colgroup.

    there is a complete videoguide you can find right here:table fix header, and row + column highlighting.

    *EDITED the answer because it was irrelevant, i read the question wrong, and answered to a totally different matter. (added a correct reply now)

    提交回复
    热议问题