I'm trying to implement a jquery live input. When user starts typing in input, list of suggestions will appear below the input. From that list of options, user should be able to click one of them and text of that option should be in the input.
Here's the process so far https://jsfiddle.net/eckae003/1/
HTML
<input type="text" name="subject" id="my_input"/>
<ul>
<li><a href="#">English</a></li>
<li><a href="#">General English</a></li>
<li><a href="#">Business English</a></li>
<li><a href="#">French</a></li>
<li><a href="#">Russian</a></li>
<li><a href="#">German</a></li>
</ul>
<span id="label"></span>
jQuery
$("ul li a").click(function(){
$("input#my_input").attr("value", $(this).text());
$("span#label").html($(this).text());
})
$("input#my_input").keyup(function(){
var text = $(this).val();
$("ul li").each(function(){
if ($(this).text().search(new RegExp(text, "i")) < 0) {
$(this).fadeOut();
} else {
$(this).show();
}
});
})
It's working on 1.8.3 version, but I wanted to do this in newer versions of jQuery.