Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery-在live搜索插件上使用提交按钮执行搜索?_Javascript_Jquery_Jquery Ui_Jquery Plugins - Fatal编程技术网

Javascript jQuery-在live搜索插件上使用提交按钮执行搜索?

Javascript jQuery-在live搜索插件上使用提交按钮执行搜索?,javascript,jquery,jquery-ui,jquery-plugins,Javascript,Jquery,Jquery Ui,Jquery Plugins,我开始使用mark.jslivesearch插件,我能够修改它,自动滚动到页面上正在搜索的文本部分 像这样: SEARCH BOX |_jklmno____| <-- User searches here 123 456 789 abcde fghi jklmno <--- Then the page will automatically scroll and stop here. pqrst $('html,body').a

我开始使用
mark.js
livesearch插件,我能够修改它,自动滚动到页面上正在搜索的文本部分

像这样:

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);
    }       
$.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);



 });
这也是:

 else if ('mark[data-markjs]').live("submit", function(e) {
      e.mark();
              $('html,body').animate(
              {scrollTop: mark.offset().top -100}
              , 200);  

    });
但它不起作用。

这里是**(为了查看搜索字段,您必须稍微滚动一下结果选项卡)

下面是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);
    }       
$.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);



 });

我用你的小提琴演奏了一会儿。
这是个很酷的问题

我决定使用上/下箭头滚动到上一个/下一个结果…
而不是输入键或按钮。

以下是我更改的主要部分:

$("input[name='keyword']").on("keyup", function(e){
    if(e.which==40){    // 40 = down arrow
        e.preventDefault();
        arrowOffset++;
    }
    if(e.which==38){    // 38 = up arrow
        e.preventDefault();
        arrowOffset--;
        if(arrowOffset<1){
            arrowOffset=1;
        }
    }
    mark(arrowOffset);
});
$(“输入[name='keyword'])。在(“keyup”上,函数(e){
如果(e.which==40){//40=向下箭头
e、 预防默认值();
箭头偏移量++;
}
如果(e.which==38){//38=向上箭头
e、 预防默认值();
箭头偏移--;

如果(arrowOffsetSo没有解决方案?说真的,到目前为止,我从未见过比你在这个脚本中所做的更棒的东西。我期待一个回车按钮,而你带着箭头和高亮显示。Thx太多了!我开始做这个工作已经有一周了。现在我有了创建按钮的基础!耶!我只是玩得很开心!这是很酷的东西,你是正在进行。请接受答案(绿色复选标记);)