Javascript 使用jquery单击删除按钮后更改行背景色

Javascript 使用jquery单击删除按钮后更改行背景色,javascript,c#,jquery,asp.net,datatable,Javascript,C#,Jquery,Asp.net,Datatable,您好,我有一个表,该表的列中有一个删除按钮,单击该按钮后,该行将高亮显示为红色。我一直在尝试一些不同的东西,但就是不起作用。如何更改confirbox()方法中行的颜色?提前谢谢你 <table id="loanSignatoriesTable" class="table table-striped table-bordered bg-light"> <thead class="bg-blue">

您好,我有一个表,该表的列中有一个删除按钮,单击该按钮后,该行将高亮显示为红色。我一直在尝试一些不同的东西,但就是不起作用。如何更改confirbox()方法中行的颜色?提前谢谢你

             <table id="loanSignatoriesTable" class="table table-striped table-bordered bg-light">
                        <thead class="bg-blue">
                            <tr>
                                <th>Emp No.</th>
                                <th>Employee Name</th>
                                <th>Rank</th>
                                <th>Designation</th>
                                <th>Group/Department</th>
                                <th>Signatory Type</th>
                                <th>Default</th>
                                <th>Status</th>
                                <th>Modified Date</th>
                                <th>Action</th>
                            </tr>
                        </thead>
      </table>

可以在函数参数中传递当前元素对象,然后在函数体中访问调用元素的父“”元素,然后更新该元素的CSS属性。 使用以下代码更新ajax中的render属性:

 "render": function (data, type, full, meta) {

                        return '<center>'
                            + '<a href="#" name="idapplication" OnClick="return ConfirmBox(this,' + 
                            data.Id + ');" value="Delete" > Delete <a/>'
                            + '<br/>'
                            + '<a href="#" name="idedit" OnClick="EditItem(' + data.Id + ');" 
                         value="Edit" > Edit <a/>'

                            + '</a>'
                        '</center >';
                         }
                        },

可以在函数参数中传递当前元素对象,然后在函数体中访问调用元素的父“”元素,然后更新该元素的CSS属性。 使用以下代码更新ajax中的render属性:

 "render": function (data, type, full, meta) {

                        return '<center>'
                            + '<a href="#" name="idapplication" OnClick="return ConfirmBox(this,' + 
                            data.Id + ');" value="Delete" > Delete <a/>'
                            + '<br/>'
                            + '<a href="#" name="idedit" OnClick="EditItem(' + data.Id + ');" 
                         value="Edit" > Edit <a/>'

                            + '</a>'
                        '</center >';
                         }
                        },
“呈现”:函数(数据、类型、完整、元){
返回“”
+ ''
'';
}
函数ConfirmBox(Elem,RefID){
$(Elem).最近('tr').css('background-color','red');
document.getElementById(“hiddenRefID”).value=RefID;
setTimeout(函数(){
如果(确认(“您确定要删除此记录吗?”)){
CallButtonEvent();
}
否则{
$(Elem).最近('tr').css('background-color','White');
}
}, 1);
}
“呈现”:函数(数据、类型、完整、元){ 返回“” + '' ''; } 函数ConfirmBox(Elem,RefID){ $(Elem).最近('tr').css('background-color','red'); document.getElementById(“hiddenRefID”).value=RefID; setTimeout(函数(){ 如果(确认(“您确定要删除此记录吗?”)){ CallButtonEvent(); } 否则{ $(Elem).最近('tr').css('background-color','White'); } }, 1); }
 "render": function (data, type, full, meta) {

                        return '<center>'
                            + '<a href="#" name="idapplication" OnClick="return ConfirmBox(this,' + 
                            data.Id + ');" value="Delete" > Delete <a/>'
                            + '<br/>'
                            + '<a href="#" name="idedit" OnClick="EditItem(' + data.Id + ');" 
                         value="Edit" > Edit <a/>'

                            + '</a>'
                        '</center >';
                         }
                        },
function ConfirmBox(Elem, RefID) {

        document.getElementById("hiddenRefID").value = RefID;
        setTimeout(function () {
            if (confirm("Are you sure you want to delete this record?")) {
                let parentTRElement = $(Elem).closest('tr').css('background', 'red');
                $(parentTRElement).css("background-color", "red");
                CallButtonEvent();
            }
            else {

            }
        }, 1);

    }
           "render": function (data, type, full, meta) {

                        return '<center>'
                            + '<a href="#" name="idapplication" OnClick="return 
                     ConfirmBox(this,' + data.Id + ');" value="Delete" > Delete <a/>'
                            + '<br/>'
                            + '<a href="#" name="idedit" OnClick="EditItem(' + data.Id 
                       + ');" value="Edit" > Edit <a/>'

                            + '</a>'
                        '</center >';
                    }



      function ConfirmBox(Elem,RefID) {

       $(Elem).closest('tr').css('background-color', 'red');
        document.getElementById("hiddenRefID").value = RefID;
        setTimeout(function () {
            if (confirm("Are you sure you want to delete this record?")) {

                CallButtonEvent();
            }
            else {
                  $(Elem).closest('tr').css('background-color', 'White');

            }
        }, 1);

    }