What is the best way to style alternating rows in a table?

后端 未结 12 537
南方客
南方客 2020-12-11 11:09

Obviously, the actual style of the odd/even rows will be done via a CSS class, but what is the best way to \"attach\" the class to the rows? Is is better to put it in the ma

12条回答
  •  萌比男神i
    2020-12-11 11:40

    It depends on your scenario. JavaScript based may be quicker to implement for a number of rows if the table is not being created on-the-fly. If you're dynamically creating your table, however, you could pretty easily set the class for every other row to be "row_alternate" -- I prefer the server side method if you are concerned that some of your users may not have JavaScript.

提交回复
热议问题