在 Javascript 代码方面需要帮助 - 如何在单击四个按钮中的一个后禁用按钮(5 个按钮)

Need assistance with Javascript Code - How to disable buttons (5 buttons) after clicking 1 of the four buttons

美好的一天,

所以我有三个包含以下脚本的页面 单击签名按钮后,我想禁用此按钮(签名按钮)以及其他 4 个按钮,例如(添加、更新、更改状态、删除)

请注意我之前提到的按钮与下面的符号脚本具有相似的脚本,只是按钮执行的实际功能不同,例如添加按钮会插入新记录,更新按钮会更新记录等)

如有任何帮助,我们将不胜感激。

脚本 1 index.php

$(document).on('click','.sign', function(){
    var expenditureid = $(this).attr("id");

    var btn_action = 'sign';
    if(confirm("Are you sure you want to sign this expenditure?"))
    {
        $.ajax({
            url:"expenditure_action.php",
            method:"POST",
            data:{expenditureid:expenditureid, btn_action:btn_action},
            success:function(data)
            {
                $('#alert_action').fadeIn().html('<div class="alert alert-info">'+data+'</div>');
                expendituredataTable.ajax.reload();
            }
        })
    }
    else
    {
        return false;
    }
});

脚本 2 action.php

            if($_POST['btn_action'] == 'sign') {
            $signed = "yes";
                $query = "
                UPDATE expenditure
                set checking_officer = :checking_officer,
                modified_by = :modified_by,
                signed = :signed

            WHERE expenditureid = :expenditureid
                ";
                $statement = $connect->prepare($query);
                $statement->execute(
                    array(
                            ':checking_officer'                     =>  $_SESSION["user_id"],
                                    ':modified_by'                      =>  $_SESSION["user_id"],
                            ':signed'                       =>  $signed,
                        ':expenditureid'                        =>  $_POST["expenditureid"]
                    )
                );

脚本 3 fetch.php

$sub_array[] = "<按钮类型='button' 名称='sign' id='".$row['expenditureid']."' class='btn btn-secondary btn-xs sign'>签名";

$sub_array[] = "<按钮类型='button' 名称='delete' id='".$row['expenditureid']."' class='btn btn-danger btn-xs delete'>删除";

你可以使用这个功能


function disable_buttons (buttons) {
 buttons.each(function(){
   $(this).attr("disabled", "disabled")
 })
}

$(".sign").on("click", function() {
  const $otherButtons = $(this).closest("tr").find("button");
  $otherButtons.prop({disabled: true});
});
<table>
  <tr>
    <td><button type="button">Update</button></td>
    <td><button type="button" class="sign">Sign</button></td>
    <td><button type="button">Delete</button></td>
    <td><button type="button">Change Status</button></td>
  </tr>
</table>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>