jQuery的自动完成:自定义“ESCAPE”的行为按键 [英] jQuery's autocomplete : customize behavior of "ESCAPE" key press

查看:67
本文介绍了jQuery的自动完成:自定义“ESCAPE”的行为按键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery的自动完成插件,并希望在用户按下ESCAPE键时自定义行为,

I am using jQuery's autocomplete plugin and want to customize the behavior when user press the "ESCAPE" key as below,


  1. 当用户键入要搜索的文本,列出其对应的结果。如果按下ESCAPE键,则不选择任何结果,则应删除输入的搜索文本。 [默认行为:保留搜索文本]
  1. when user types text to search, its corresponding results are listed. Without selection any result if "ESCAPE" key is pressed, then the search text entered should be removed. [Default Behavior: the search text is retained]

  1. http://jqueryui.com/demos/autocomplete/#multiple-remote ,用户可以多次搜索。假设他输入了一个文本并从下拉列表中选择了一行。现在,他再次搜索,但没有选择任何结果,他按ESCAPE键,然后应该删除单独的搜索字符串(而不是之前选择的搜索字符串)。

  1. In http://jqueryui.com/demos/autocomplete/#multiple-remote, user can search multiple times. Assume, he has entered a text and has selected a row from the drop down. Now, he searches again, but without selecting any result, he presses "ESCAPE" key, then the search string alone should be removed (and not the previously selected one).


感谢任何帮助。

推荐答案

类似这样的事情

$(document).ready( function() {
    $("#birds").keypress(function (e) {
          if(e.keyCode == 27) {
            $("#birds").val("");
          }}
        });  
});

这篇关于jQuery的自动完成:自定义“ESCAPE”的行为按键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆