disable two buttons after clicking another button



PHP Snippet 1:

$(document).ready(function(){
  $("#reject_button").click(function(){
     $("#approve_button, #return_button").attr("disabled","true");
  });
});

PHP Snippet 2:

<script>
//you can replace querySelector with getElementById, but I prefer the flexibility of query selector
  document.querySelector('#reject_button').addEventListener('onclick', () => {
    document.querySelector('#approve_button').setAttribute('disabled',"");
    document.querySelector('#return_button').setAttribute('disabled',"");
  });
</script>

PHP Snippet 3:

<div class="text-center ">

    <?php if(isset($_SESSION['disable-buttons']) ){
                if($_SESSION['disable-buttons'] == true){

                    $disabled = "disabled";

                }else{

                $disabled = "";
                
                } 
        }

     ?>

    <button class="btn m-1 align-items-center btn-success text-center " type="submit" id="approve_button" data-toggle="modal" data-target="#approveModal" <?php echo $disabled ?> >Approve</button>   
    <button class="btn btn-secondary m-1 align-items-center text-center" type="submit" id="return_button" data-toggle="modal" data-target="#returnModal" <?php echo $disabled ?> >Return</button>       
    </div>


<div>
<button class="btn btn-danger m-5 align-items-center text-center"  id="reject_button" name="reject_button" data-toggle="modal"data-target="#rejectModal" >Close Task</button>
</div>
<?php 
if (isset($_POST["reject_button"])){ 

    $_SESSION['disable-buttons'] = true; 
    
    $rejectt = mysqli_real_escape_string($con, $_POST["rejectt"]);
    $sql = "UPDATE task SET task_status='closed'  WHERE id_task='$rejectt' ";
    $result_rej = mysqli_query($con, $sql);
    if ($result_rej) {
        $_SESSION['success'] = "Task closed";
        $_SESSION['text'] = "Task has been closed successfully";
        $_SESSION['icon'] = "success";
   
    } else {
        $_SESSION['success'] = "Error";
        $_SESSION['text'] = "Unknown error, please try again";
        $_SESSION['icon'] = "error";
    }

 }
?>
   <?php
    if (isset($_SESSION['success']) && $_SESSION['success'] != '') {
    ?>
        <script>
            swal({
                title: "<?php echo $_SESSION['success']; ?>",
                text: "<?php echo $_SESSION['text']; ?>",
                icon: "<?php echo $_SESSION['icon']; ?>",
                button: "OK";
                
            });
        </script>
    <?php
        unset($_SESSION['success']);
    }
    ?>