如何在带有条件的html文本框中添加颜色?

时间:2016-07-11 08:26:19

标签: javascript jquery html jqgrid-asp.net

大家好,如何在cshtml中更改文本框的颜色?我有这个代码

$("#BUTTON").click(function (event) {
    var urlPA = URL;
    var crty = $("#Courtesy").val();
    var fname = $("#Familyname").val();
    var gname = $("#GivenName").val();

    if (crty != 0 && fname != 0 && gname != 0) {
        $.ajax({
            type: "GET",
            url: urlPA,

            data: 'DATA',
            success: function (response) {
                alert(response);
            /// when success the color of the textbox return to normal
            },
            datatype: "text"
        });
    } else { alert("Please fill up the required fields.");
     ////// when error the textbox background makes red

}
});

怎么做?感谢。

1 个答案:

答案 0 :(得分:0)

您可以使用jQuery的css函数来设置内联样式:

.controller('yourCtrl', function ($http, $scope) {
    var i=1; 
    $scope.result=[];   
     $scope.loadMore = function () {
            $http.get( "http://test.website.com/api/search/"+i).then(function (data) {
                $scope.result = data;
                $scope.$broadcast('scroll.infiniteScrollComplete');

            });
        }


        $scope.categories = [];
        $http.get( "http://test.website.com/api/search/"+i).then(function (returnData) {
            $scope.result = returnData;
        }, function (err) {
            console.log(err);
        })



  })