The button is not one, how to make the text of this button change when you click? Here is the code:

<button class="btn btn-success btn-lg add-to-order" value="Добавить к заказу" onclick="" id="123"></button> <script type="text/javascript"> $('#123').click(function() { $('#123').val('Добавлено к заказу'); }); </script> 

It doesn't work

    2 answers 2

     $('.add-to-order').click(function() { $(this).text('Добавлено к заказу') .css('background-color', '#ff0000'); }); 
     <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <button class="add-to-order">Добавить к заказу</button> <button class="add-to-order">Добавить к заказу</button> <button class="add-to-order">Добавить к заказу</button> 

    • Tell me how to turn to the background-color property and make the button in a different color? - Alexander
    • one
      @Alexander added in response - Vadim Leshkevich

    And so will not work?

     <button class="add-to-order" onclick="this.innerText='Добавлено';">Добавить к заказу</button> <button class="add-to-order" onclick="this.innerText='Добавлено';">Добавить к заказу</button> <button class="add-to-order" onclick="this.innerText='Добавлено';">Добавить к заказу</button> 

    Cheap, angry and without Zhkver.