jQuery22 Jul 2008
jQuery was able to simplify some of the things I would have had to write nasty looking View code otherwise.
For example, I wanted to alternate every other row in a table with a different color. To do this in the View I initially created a counter variable and did a mod 2 to apply the CSS class. Once I integrated jQuery I was able to remove that messy code throughout my entire View and just replace it with…
3: $("#tblList tr:odd").addClass("alternatingRow");
4: $("#tblList tr:even").addClass("row");
After I got a little familiar with jQuery I branched out and used it to create an accordion navigation menu with little effort.
1: $("#menu li div.subMenuItems").hide();
2: $("#menu li div.parentMenuItem").click(function()
4: $("#menu li div.subMenuItems:visible").slideUp("slow");
6: return false;
There are several other helpful areas in my ASP.NET MVC application that I found jQuery to be very convenient, efficient, and resulted in a cleaner code base.
If you haven’t used jQuery before I highly recommend you check it out.