How to Set Alternate Color of div using jQuery

Use this method, if you want to set alternate color of div without parameter.

     function SetAlternateColor() {
        var count = 0;
        $j('#MainDiv > div').each(function() {
            $j('#' + this.id).removeClass("BkgndClass");
            if (count % 2 != 0)
                $j('#' + this.id).addClass("BkgndClass");
            count = count + 1;
        });
        return count;
    }

Use this method, if you want to set alternate color of div with parameter.

    function SetAlternateColor(empId) {
        var count = 0;
        $j('# MainDiv_' + empId + ' > div').each(function() {
            $j("#" + this.id).removeClass("
BkgndClass");
            if (count % 2 != 0) {
                $j("#" + this.id).addClass("
BkgndClass");
            }
            count = count + 1;
        });
        return count;
    }