Stop reloading page with 'Enter Key'

前端 未结 9 1052
臣服心动
臣服心动 2020-12-25 10:11

I have a search box at the top of page that makes an ajax call when a user hits the adjacent button. I am trying to update the input tag so that when a user hit the \'en

9条回答
  •  孤城傲影
    2020-12-25 10:58

    You are missing # in the selector. Try this

    
    

    JS

    $("#searchText").bind('keyup', function(event){ 
      if(event.keyCode == 13){ 
        event.preventDefault();
        //$("#buttonSrch").click(); 
        search(this.value);
      }
    });
    

提交回复
热议问题