jquery - How to style alternating rows in asp.net mvc -


I use a & lt;% foreach ...%> loop for the list of items collection on my website I am here.

I want to add a different background color to the style of the optional rows in my list. I have found a way to do this but I am not satisfied with it because it sounds like a hack.

Even I have solved it so far:

  & lt; Table & gt; & Lt;% int counter = 0; Leading (different items in the model) {counter ++; If (counter% 2 == 0) {%> & Lt; Tr class = "colorfull" & gt; & Lt;%} Other {%> & Lt; TR & gt; & Lt;%}% & gt; ...  

Am I recalling that people are using ASP.NET MVC for this scenario?

I got the JPIT code of this code, which I find very clean.

  $ (document) .ready (function () {$ ("table tr: nth-child (strange)"). AddClass ("colorfull");});  

I have removed counter logic, this JQuery script adds DOM to set the second class of the CSS class in the foam loop.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

kernel - How to create a "Block device" in Windows -