简体   繁体   中英

css Property for jquery ajax success function

I'm working with MVC3, using the following jQuery AJAX call:

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');            
            }
        }     
    }); 
}

I want to set the CSS property for success function:

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

I want to add the following CSS property in the above line:

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

Where do I need to insert this line?

Add it after the "for" statement.

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");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM