0

我正在使用 MVC3,使用以下 jQuery AJAX 调用:

function Displaymaingrid () { 
    var Geo = $('#ddlGeo').val();
    var Vertical = $('#ddlVertical').val();
    var Month = $('#ddlMonth').val();

    if(Vertical == "All")
    {
        var Flag = 1;
    }
    else
    {
        var Flag = 2;
    }      
    $.ajax({
        url: "@Url.Action("TRUnutilizedOwnershipChange", "TravelReady")",
        datatype: "html",
        type: "post",
        data: {strGeo:Geo, strVertical:Vertical, intMonth:Month, intFlag:Flag},
        error: function(){},
        success: function(data){
            $('.travTableContent').empty();
            var text3 = data.data.lstunutilizedownershipentities;
            for( var item in text3)
            {                   
                $('<tr />').html(text3[item]).appendTo('.travTableContent');            
                $('<td />').html(text3[item].CurrentOwnership).appendTo('.travTableContent');
                $('<td />').html('<a href="#" onclick="javascript:GetDetail(\'' + text3[item].CurrentOwnership + '\');">' + text3[item].cnt + '</a>').appendTo('.travTableContent');            
            }
        }     
    }); 
}

我想为成功功能设置 CSS 属性:

$('<tr />').html(text3[item]).appendTo('.travTableContent'); 

我想在上面的行中添加以下 CSS 属性:

("tr:odd").css("background-color", "#d0d1e2") 

我需要在哪里插入这一行?

4

1 回答 1

0

在“for”语句之后添加它。

for( var item in text3){                   
        $('<tr />').html(text3[item]).appendTo('.travTableContent');            
        $('<td />').html(text3[item].CurrentOwnership).appendTo('.travTableContent');
        $('<td />').html('<a href="#" onclick="javascript:GetDetail(\'' + text3[item].CurrentOwnership + '\');">' + text3[item].cnt + '</a>').appendTo('.travTableContent');            
}
$("tr:odd").css("background-color", "#d0d1e2");
于 2013-07-24T03:41:10.213 回答