I have the following jQuery code:
function showResult(str)
{
if (str.length == 0)
{
$('#mySearch').html('');
return;
}
else
{
$('#mySearch').load('search/'+str,function(){
$('#mySearch').css({
'background-color': 'white',
'width': '250px',
'position': 'absolute',
'right': '0'
})
});
}
$(document).click(function(event) {
if ( !$(event.target).hasClass('mySearch'))
{
$('#mySearch').html('');
$('#main_search').val('');
}
});
$(document).keydown(function(e){
if (e.keyCode == 40) {
$('#mySearch tr.myRow:first').addClass("a_classy_class");
return false;
}
});
}
When I press the down arrow key the class 'a_classy_class' is added to the tag with id 'myRow'. However, as soon as I stop pressing the down arrow key the class is removed. How do I make the change permanent, so that after I stop pressing the down arrow key the change holds?