Add striped styling to a list of items

前端 未结 6 1078
执笔经年
执笔经年 2021-02-01 17:43

What would be the best way to stripe a list with KnockoutJS? The class on the div below should be even or odd depending where it is in the list, and update when adding or removi

6条回答
  •  时光说笑
    2021-02-01 17:53

    Thanks for the helpful posts. I wanted to mention that css can do a good job of striping but the embedded 'if' only seems to function after the row has been rendered. Therefore, using $index or the css odd/even capabilities don't yield the desired results. Without using a template I found that you can wrap the KO logic around the row so that the logic occurs before the row is counted.

    
        
        
                
        
        
    
    

提交回复
热议问题