マウスオーバーで垂直にスクロールする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>
ただし、私の問題は次のとおりです。検索語を入力すると、表示されているメニュー項目のみが強調表示されます。div内の検索語にjqueryを自動的にスクロールさせるにはどうすればよいですか?