On my page there are a lot of buttons, and the forms that these buttons open. By clicking submit on the form - the button becomes inactive.
<div class="rows"> <!------------------------1 button------------------------> <div class="row"> <button class="open">btn1</button> <form id="myform" onsubmit="return false;"> <div class="form-group"> <label for="exampleInputEmail1">Name</label> <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email"> </div> <div class="form-group"> <label for="exampleInputPassword1">Phone</label> <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password"> </div> <button class="ave">close</button> <button id="submit" class="close">Submit</button> </form> </div> <!----------------------------------------------------> </div> Jquery:
$(function() { $('.row').on('click', '.open', function() { $(this).parent().children('form').show(); $(this).attr('disabled', true); } ); $('.row').on('click', '.close', function(e) { e.preventDefault(); $(this).closest('.row').find('.open').html('Куплено!'); $(this).parent('form').html('Мы вам перезвоним!!!').delay(2000).toggle(500); } ); $('.row').on('click', '.ave', function(e) { e.preventDefault(); $(this).parent('form').hide(); $(this).closest('.row').find('.open').prop('disabled', false); } ); } ); Is it possible to make the form only one, and not for each button? This approach makes the code very long. And to all forms open for each button, and I need to only for one - pressed at the moment. Thanks for reading.
Here's what it looks like. The buttons of the same type, each with its own form. It is necessary to keep the functionality, but so that it is impossible to open many forms at once.
