My page has a textbox.User will enter a one character in it.That character i have to match with the list item values and if match occur all values will be printed.Suppose user enter “T”,then all list items starting with “T” will be printed.
This is Html code.
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
<input type="text" id="text1" class="cal" />
<input type="button" value="calculate" id="Button2" />
This is JQuery Code.
$(document).ready(function() {
$("#calculate").click(function() {
var getsValue = $("#textbox1").val();
$("ul > li").each(function() {
if (getsValue == $(this).text()) {
"print here"
}
else {
alert("no")
}
});
});
});
It is working if i enter whole string but i need to enter only one character.
Please help.
Thank you.
DEMO