1
滚动格菜单
我有jQuery的滚动菜单上的鼠标悬停垂直滚动:(它的一部分被隐藏,直到滚动到视图)搜索与jQuery
<script type="text/javascript">
$(document).ready(function() {
//Scroll the menu on mouse move above the #sidebar layer
$('#sidebar').mousemove(function(e) {
//Sidebar Offset, Top value
var s_top = parseInt($('#sidebar').offset().top);
//Sidebar Offset, Bottom value
var s_bottom = parseInt($('#sidebar').height() + s_top);
//Roughly calculate the height of the menu by multiply height of a single LI with the total of LIs
var mheight = parseInt($('#menu li').height() * $('#menu li').length);
//Calculate the top value
//This equation is not the perfect, but it 's very close
var top_value = Math.round(((s_top - e.pageY)/100) * mheight/2);
//Animate the #menu by chaging the top value
$('#menu').animate({
top: top_value
}, {
queue: false,
duration: 5000
});
});
});
</script>
,然后我使用的是搜索和突出的jQuery脚本在滚动菜单搜索名称:
<script type="text/javascript">
$(function() {
$('#text-search').bind('keyup change', function(ev) {
// pull in the new value
var searchTerm = $(this).val();)
// remove any old highlighted terms
$('#sidebar').removeHighlight();
// disable highlighting if empty
if (searchTerm) {
// highlight the new term
$('#sidebar').highlight(searchTerm);
}
});
});
</script>
但我的问题是:当我在搜索词输入,它只会突出可见的菜单项。我如何让jquery自动滚动到div中搜索到的术语?
是的,这不适合我 - 可以更具体地说明我将它放在代码中的位置吗?谢谢! – user1604408 2012-08-16 21:58:48
我会尽力为你做一个工作演示。你能给我你正在使用的HTML吗?将我的一些时间从你的js反向工程节省。 – lupos 2012-08-17 13:46:43
好的 - 你有没有可以发送给我的电子邮件,让它更容易? – user1604408 2012-08-17 15:25:33