CSS Alternate Rows - some rows hidden

前端 未结 6 1280
遥遥无期
遥遥无期 2021-02-12 11:45

I\'m trying to style a table so that each row is a different colour (odd/even). I have the following CSS:

#woo tr:nth-child(even) td {
    background-color: #f0f         


        
6条回答
  •  粉色の甜心
    2021-02-12 11:54

    If you are using jQuery, you can employ one of its functions, for example .filter(), to choose only the elements that are visible. But the key here is a CSS selector :visible.

    For example (see jsfiddle):

    jQuery('tr:visible:odd').css({'background-color': 'red'});
    jQuery('tr:visible:even').css({'background-color': 'yellow'});
    

提交回复
热议问题