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
Post a Comment