$(".inv_item").click(function(event){ $(".set_input").val($(this).children("p").html() + "/"); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button class=inv_item>Добавить<p> этот текст</button> <input value="тут уже что-то есть" class=set_input> 

Actually in this code, when you click on .inv_item, the text is entered into the input with the class .set_input. But the problem is that with each press, the text in the input is replaced with a new one, but I need the old text not to be deleted and the new one added after it.

    1 answer 1

     $('.set_input').val($('.set_input').val() + $(this).children("p").html() + "/"); 

    Think so.

    • one
      $ ('. set_input'). html () ??? - Igor
    • Unfortunately did not work. - Bim Bam
    • @BimBam, try with .val () fixed. If it does not work, then the essence itself is to get the previous value and concatenate what is needed at the end, and install it. - DanielOlivo
    • Yes. It worked. Graz - Bim Bam
    • @BimBam mark the answer as correct, if he answered your question - Vasily Barbashev