jQuery.each() Demo

ISBN Title Media Price Inventory Favorite
978-0-470-45733-7 DotNetNuke and Web Standards eBook $6.99 -1 User Favorite
978-0-470-43870-1 Professional DotNetNuke 5 Paperback $49.99 55 Not a Favorite
978-0-470-46257-7 DotNetNuke 5 User's Guide Paperback $49.99 10 Not a Favorite
978-0-470-17116-5 Professional DotNetNuke Module Programming Paperback $49.99 5000 Not a Favorite

JavaScript Source

/* Callback constructor */
jQuery(function() {

    /* Iterate over all the rows in the table body */
    $("#example tbody>tr").each(function() {

        /* Your custom business logic goes here */
        /* Here we see the use of the eq() method to reduce the set of elements */
        switch ($.trim($("td", this).eq(2).text())) {
            case 'eBook':
                FormatEbook($(this));
                break;
            case 'Paperback':
                FormatPaperback($(this));
                break;
        }
    });
});

function FormatEbook(tr) {
    tr.css("font-style", "italic");
}

function FormatPaperback(tr) {
    /* Using selectors, I can also limit the elements using the :eq() filter */
    var inv = parseInt(tr.children("td:eq(4)").text());
    if (inv <= 100 && inv > 10) {
        tr.addClass("warn");
    }
    else if (inv <= 10) {
        tr.addClass("critical");
    }
}