jquery element select on keyboard keypress code -


i have ul list , want change background color of li when press key on keyboard. example. press a on keyboard , change background of li text a.

<ul>     <li>a</li>     <li>b</li>     <li>2</li> </ul> 

which best , simple way this?

you this...

var li = $("ul li");  $(document).keypress(function(event) {      li       .filter(function() {           return $(this).text() == string.fromcharcode(event.which).tolowercase();       })       .css("background-color", "#f00"); }); 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -