Hello, how can I add search elements to the value input tag without refreshing the page so that it can later be written to the database. enter image description here So that when the user clicked on the search result and this text appeared on the input without updates.

    1 answer 1

    $(function() { $('p').click(function(){ // отлавливаем нажатие на результат поиска var adres = $(this).text(); // получаем текст который соответствует выбраному нами результату поиска $("#poisk").attr("value", adres); //записываем текст в инпут (меняем значение value) }); }); 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="text" id="poisk" /> <p>Результат 1</p> <p>Результат 2</p> <p>Результат 3</p> <p>Результат 4</p>