我在一个输入字段(Div)下面有一个urls列表(Div)。我需要在列表中下降的能力,然后通过点击回车,这将触发一些指定给网址的功能。这是fidle:the script
在过去的几天里,我试图解释很多事情,但最终都没有奏效。如果能帮上忙,我们将不胜感激。
发布于 2011-05-20 23:38:49
在这行代码之后:
// set timers to do automatic hash checking and suggestions checking
setInterval(checkHash,500);
setInterval(checkSuggest,500);插入以下内容:
$('#searchbox').keyup(
function (e){
var curr = $('#suggest').find('.current');
if (e.keyCode == 40)
{
if(curr.length)
{
$(curr).attr('class', 'display_box');
$(curr).next().attr('class', 'display_box current');
}
else{
$('#suggest li:first-child').attr('class', 'display_box current');
}
}
if(e.keyCode==38)
{
if(curr.length)
{
$(curr).attr('class', 'display_box');
$(curr).prev().attr('class', 'display_box current');
}
else{
$('#suggest li:last-child').attr('class', 'display_box current');
}
}
if(e.keyCode==13)
{
var search_terms = $('.current a').text();
// perform a search with this text...
doSearch(search_terms,true,false);
//update the search textbox
$('#searchbox').val(search_terms);
}
})
And don't forget to delete the previous code at the bottom...https://stackoverflow.com/questions/6074250
复制相似问题