Set Alternate color for GridView columns using jQuery

In this post, we will see how easily we can assign background color to ASP.NET Grid Views columns using jQuery. In this example, we will assign "Tan" color to all the even columns of GridViews and "PaleGoldenrod" to even columns. When I say Odd, that means columns which are having odd numbers like column1, column3 etc.

$(document).ready(function() {
  $("#<%=gdRows.ClientID%> td:nth-child(odd)").css("background-color", "Tan");
  $("#<%=gdRows.ClientID%> td:nth-child(even)").css("background-color", "PaleGoldenrod");
});

Feel free to contact me for any help related to jQuery, I will gladly help you.



Responsive Menu
Add more content here...