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.

Nothing shocks me, I'm a Software Engineer. And I am not young enough to know everything. I live in World Wide Web and from there take care of this website. This website communicates about my work, learning and experience. I believe life is short, and it is for loving, sharing, learning and connecting. So lets connect..