JQuery Row Selection & Changing Styles

JQuery can be extremely FAST as compared to normal Javascript routines. Like in case we want to select a row in html table, and want to change the style of that row, and also remove selected style from other rows of the same table. (Options are limitless)

function SelectRow(rowObject)


    $(“#tableId TR “) .removeClass(“SelectedRowStyle”).addClass(“OriginalRowStyle”);//removes SelectedRowStyle and add Original

  //Option – more faster can be $(“#tableId TR .SelectedRowStyle”) .removeClass(“SelectedRowStyle”).addClass(“OriginalRowStyle”);

   $(this).removeClass(“OriginalRowStyle”).addClass(“SelectedRowStyle”); //removes the Original Style and add Selected class


Now, if wanted to the same in Javascript we would need to loop through all rows and then search for selected row and do all other stuff we need to for javascript. This is simple in its own way…


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.