I have unordered list with single character in every li. If a user pressed any letter on the keyboard I wanted to add css class to the corresponding li on my page . If the user pressed A on the keyboard, I want to find the li that has A as its content and add css class to it
<div>
<ul class ='list'>
<li>a</li>
<li>b</li>
<li>c</li>
...
<li>z</li>
</ul>
</div>
This is how i started it
$(document).keypress(function(e){
var x = e.which;
if((x >= 65 && x <= 90)||(x >=97 && x <= 122)||(x >=48 && x <= 57)) {
checkfirst(x);
}
});
// pick list item with the text content of the value passed
function checkfirst(x){
var y = $('.list').find('li');
// code will go here
//am trying to find the li with text equal to the argument passed
}