There is a table. There is an add button that, when clicked, adds a new row to the table. I want to make the button only active once. Or maybe it can somehow hide?

$('.add').click(function(){Π΄ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ строки ΠΏΠΎ Π½Π°ΠΆΠ°Ρ‚ΠΈΡŽ} 

Tell me how this can be implemented?

  • jquery-docs.ru/one - user207618
  • $ ('. add'). click (function () {$ (this) .hide ()}); - Pyramidhead

3 answers 3

 $(document).ready(function() { $('#two').click(function() { $(this).attr('disabled', true); // Π›ΠΈΠ±ΠΎ Π΄ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ Π°Ρ‚Ρ€ΠΈΠ±ΡƒΡ‚ disabled }); $('#one').click(function() { $(this).hide(); // Π›ΠΈΠ±ΠΎ ΡΠΊΡ€Ρ‹Ρ‚ΡŒ }); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button id="one">Π‘ΠΊΡ€Ρ‹Ρ‚ΡŒ</button> <button id="two">Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ Π°Ρ‚Ρ€ΠΈΠ±ΡƒΡ‚ disabled</button> 

     $('.add').css("display", "none"); 

    In the click function, if you still need to hide.

     $(".add").attr('disabled',true); 

    If done inactive.

       $('.add').click(function(){ // ΠΊΠΎΠ΄ добавлСния ΠΈ всякиС Ρ‚Π°ΠΌ манипуляции $(this).remove() - ΡƒΠ΄Π°Π»ΠΈΡ‚ΡŒ // ΠΈΠ»ΠΈ $(this).hide() - ΡΠΊΡ€Ρ‹Ρ‚ΡŒ // ΠΈΠ»ΠΈ $(this).attr('disabled', true); - нСактивная (Ссли button, ΠΈΠ»ΠΈ input submit) }