JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<input type="text" class="form-control empty" name="keyword" id="pickup" placeholder="" />
<div id="results"></div>
JavaScript
$(document).ready(function() {
// This code is to simulate the response of the AJAX call.
var data = ['a', 'b', 'c', 'd', 'e', 'f', 'g'].reduce(function(memo, val) {
memo += '<a style="cursor:pointer">' + val + '</a>';
memo += '<br />';
return memo;
}, '');
// This code is analog to the one in the AJAX success callback with the addition of removing the links.
$("#results").html(data);
$("#results").slideDown('fast');
// use `on` as elements are added dynamically
$("#results").on("click", "a", function() {
// take `text` of a clicked element and set it as `#pickup` value
$("#pickup").val($(this).text());
$("#results").html(this);
});
});