如何在前端扣除值1? 我编写代码是为了减少后端的值,但我也使用jquery编写ajax回调响应来减少前端的值。但是前端代码没有减少任何值。当用户单击“删除”按钮时,它将删除该行,同时需要从总计数中扣除1。 我的html计数: 参赛作品总数 我的ajax前端代码: $(文档)。在('单击','上。删除btn',函数(){ 喷火({ 标题:“你确定吗?”, 文本:“您将无法还原此内容!”, 键入:“警告”, showCancelButton:true, confirmButtonColor:“#3085d6”, cancelButtonColor:“#d33”, confirmButtonText:“是的,删除它!” })。然后((结果)=>{ if(result.value){ 设currentTrId=this.id; $.ajax({ 方法:“张贴”, url:“/delete”, 数据:{“taskId”:this.id}, 成功:功能(结果){ 日志(“响应:”,结果); 喷火( “已删除!”, “您的任务已被删除。”, “成功” )。然后((删除结果)=>{ $('#entrycount').html(parseInt($('#entrycount').html())-1); $(“#”+currentTrId).淡出(“正常”,函数(){ $(this.remove(); }); } }) } 否则{ console.log(document.getElementById(this.id)[0]) console.log($(this.parent().parent()[0]) console.log(this.id) } }); });

如何在前端扣除值1? 我编写代码是为了减少后端的值,但我也使用jquery编写ajax回调响应来减少前端的值。但是前端代码没有减少任何值。当用户单击“删除”按钮时,它将删除该行,同时需要从总计数中扣除1。 我的html计数: 参赛作品总数 我的ajax前端代码: $(文档)。在('单击','上。删除btn',函数(){ 喷火({ 标题:“你确定吗?”, 文本:“您将无法还原此内容!”, 键入:“警告”, showCancelButton:true, confirmButtonColor:“#3085d6”, cancelButtonColor:“#d33”, confirmButtonText:“是的,删除它!” })。然后((结果)=>{ if(result.value){ 设currentTrId=this.id; $.ajax({ 方法:“张贴”, url:“/delete”, 数据:{“taskId”:this.id}, 成功:功能(结果){ 日志(“响应:”,结果); 喷火( “已删除!”, “您的任务已被删除。”, “成功” )。然后((删除结果)=>{ $('#entrycount').html(parseInt($('#entrycount').html())-1); $(“#”+currentTrId).淡出(“正常”,函数(){ $(this.remove(); }); } }) } 否则{ console.log(document.getElementById(this.id)[0]) console.log($(this.parent().parent()[0]) console.log(this.id) } }); });,html,jquery,express,mongoose,ejs,Html,Jquery,Express,Mongoose,Ejs,当用户单击ajax请求上方的“删除”按钮时,后端表中的行被删除,行的计数值减少。响应将从前端到前端。当用户单击“删除”按钮时,我可以删除前端的行,但无法减少计数值。我如何实现这一点?我尝试了不同的方法,但没有用。为什么您这样做#此处id=“#entrycount”删除并重试一次小错误消耗2小时的时间,谢谢你现在它正在工作为什么你有#此处id=“#entrycount”删除并重试一次小错误消耗2小时的时间,谢谢你现在它正在工作 I write the code to reduce the valu

当用户单击ajax请求上方的“删除”按钮时,后端表中的行被删除,行的计数值减少。响应将从前端到前端。当用户单击“删除”按钮时,我可以删除前端的行,但无法减少计数值。我如何实现这一点?我尝试了不同的方法,但没有用。

为什么您这样做
#
此处
id=“#entrycount”
删除并重试一次小错误消耗2小时的时间,谢谢你现在它正在工作为什么你有
#
此处
id=“#entrycount”
删除并重试一次小错误消耗2小时的时间,谢谢你现在它正在工作
I write the code to reduce the value in backend but I also write the ajax call back response to reduce the value in front end using jquery. But the front end code is not decrease any value. When user click on delete button it remove the row and at the same time it need to deduct the 1 from total count. 
My html count :
   <div class="col-lg-3">
            <div class="widget style1 navy-bg">
                <div class="row">
                    <div class="col-3">
                        <i class="fa fa-cloud fa-5x"></i>
                    </div>
                    <div class="col-8 text-right">
                        <span>Total Entries </span>
                        <h2 id="#entrycount" class="font-bold "><%= Count%></h2>
                    </div>
                </div>
            </div>
        </div>
My ajax front end code: 
 $(document).on('click', '.delete-btn', function () {
        Swal.fire({
            title: 'Are you sure?',
            text: "You won't be able to revert this!",
            type: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: 'Yes, delete it!'
        }).then((result) => {
            if (result.value) {
             let currentTrId = this.id;
                $.ajax({
                    method: "POST",
                    url: "/delete",
                    data: { "taskId": this.id },
                    success: function (result) {
                        console.log("Response :", result);
                        Swal.fire(
                            'Deleted!',
                            'Your Task has been deleted.',
                            'success'
                        ).then((deleteResult) => {
                            $('#entrycount').html(parseInt($('#entrycount').html()) - 1);         
                            $("#" + currentTrId).fadeOut("normal", function () {
                                $(this).remove();   
                            });
                    }
                })
            }
            else {
                console.log(document.getElementById(this.id)[0])
                console.log($(this).parent().parent()[0])
                console.log(this.id)
            }
        });
    });