How to display alternate color in table using Jquery Selector


While working with mvc project, we will get scenario to display the alternate color of tabular grid. We can do this task using Jquery selector in very easy way like this

<!DOCTYPE html>
<html xmlns="">
     <script src="../Scripts/jquery.min.js"></script>
        $(function () {
            $("tr:odd").css("background-color", "yellow");
        <legend><b>Alternate table row color using Jquery selector</b></legend>
    <table border="1">
            <th>Contact Num</th>

Note: in above example we have used $(“tr:odd”) as Selector


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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.

%d bloggers like this: