1
Good afternoon, everyone,
I am trying to implement the following solution:
By clicking the button element I want the input field to be enabled.
But by clicking the button nothing happens. Could anyone help me identify what the problem of my code?
index.html
<!DOCTYPE html>
<head>
<meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Pain Free</title>
    <meta name="description" content="Site voltado para manipular doencas de pacientes que utiizando o app do pain free">
    <meta name="Laura" content="">
    <link rel="stylesheet" href="./css/index.css">
    <link rel="stylesheet" href="./css/menu.css">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
      <link rel="stylesheet" href="css/ie.css">
    <![endif]-->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
    <script src="js/responsive-nav.js"></script>
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>      
</head>
<body>
 <section id="profile_doctor">
        <div class="container_profile_doctor">
            <div class="form-row">
                <div class="form-group col-md-6">
                  <img src="doctor.png" alt="avatar doctor" id="avatar_profile_doctor" 
                  class="rounded mx-auto d-block"
                  width="180" height="180"/>
                </div>
            </div>
            <form  action="" method="POST">
              <div class="form-row">
                <div class="form-group col-md-6">
                    <input type="text" name="name" class="form-control" id="doctor_name" disabled="true" placeholder="Nome">
                  </div>
                <button type="submit" class="btn btn-primary" id="btn_edit_profile_doctor">Editar</button>
              </div>
              <div class="form-row">
                  <div class="form-group col-md-6">
                    <input type="text" name="occupation" class="form-control" id="doctor_occupation" disabled="true" placeholder="Profissão">
                  </div>
                  <button type="submit" class="btn btn-primary" id="btn_edit_profile_doctor">Editar</button>
                </div>
           </form>
            </div>
        </section>
<script src="js/fastclick.js"></script>
<script src="js/scroll.js"></script>
<script src="js/fixed-responsive-nav.js"></script>
Code jQuery
<script>
  $(document).ready(function()
  {
    $(':button').click(function()
    {
        var inputText = $('.form-control').attr('disabled',true);
    }
    );
  }
  );
</script>
						
Change . attr('disabled',true) to removeAttr('disabled');
– Sumback
Enabled the first time and disabled again. Now no more.
– Laura Regina
Try this: $('. form-control'). toggle('disable');
– Sumback
Possible duplicate of How to enable and disable fields by clicking button
– LeAndrade