mark.js
ライブ検索プラグインを使い始めましたが、ページ上で検索されているテキスト部分に自動的にスクロールするように変更することができました。このようjQuery - ライブ検索プラグインの[送信]ボタンを使用して検索を実行するには?
:
SEARCH BOX |_jklmno____| <-- User searches here
123
456
789
abcde
fghi
jklmno <--- Then the page will automatically scroll and stop here.
pqrst
- >完了、それが見つかったテキスト< -
コードは、私が提出されたときに、ページがにジャンプしますというボタンを構築することができますどのように、作品次の結果?
私は、フォームが送信されたときに次の結果にジャンプするためにこれを使用してみました:
$('html,body').animate({scrollTop: mark.eq(index).offset().top}, 500);
}
あまりにもこの:
else if ('mark[data-markjs]').live("submit", function(e) {
e.mark();
$('html,body').animate(
{scrollTop: mark.offset().top -100}
, 200);
});
しかし、それは動作しませんでした。
はここでここworking fiddle **(検索フィールドを参照するためには、あなたは結果タブを少しスクロールする必要が)
とは、jQueryのです:
$.noConflict()
jQuery(function($) {
var mark = function() {
// Read the keyword
var keyword = $("input[name='keyword']").val();
// Determine selected options
var options = {
"filter": function(node, term, counter, totalCounter){
if(term === keyword && counter >= 1){
return false;
} else {
return true;
}
},
done: function() {
var mark = $('mark[data-markjs]');
if (mark.length) {
$('html,body').animate({scrollTop: mark.eq(index).offset().top}, 500);
}
/*
else if ('mark[data-markjs]').live("submit", function(e) {
e.mark();
$('html,body').animate(
{scrollTop: mark.offset().top -100}
, 200);
});
*/
}
};
$("input[name='opt[]']").each(function() {
options[$(this).val()] = $(this).is(":checked"); });
// Mark the keyword inside the context
$(".context").unmark();
$(".context").mark(keyword, options);
};
$("input[name='keyword']").on("keyup", mark);
$("input[type='checkbox']").on("change", mark);
$("input[name='keyword']").on("submit", mark);
});
解決策はありませんか? – Matty