简体   繁体   English

jQuery-听用户单击浏览器提供的“自动建议”选项

[英]jQuery - Listen to User click on the Auto Suggest Option provided by browser

This is my input box. 这是我的输入框。

<input type="text" class="form-control" id="contestCode" name="contestCode" required >

My jQuery Snippet which checks for keyup event and paste event 我的jQuery代码段,用于检查keyup事件和paste事件

$('#contestCode').on({
            keyup : function(){
                checkContestCodeIfExists($(this));
            },
            paste : function(){
                checkContestCodeIfExists($(this));
            }
    });

But when the user clicks on the autoSuggest provided by the browser (Code exists for the auto suggest provided by the browser because I already gave that code as input once) ,I am not able to listen to that event. 但是,当用户单击浏览器提供的autoSuggest时浏览器提供的自动建议的代码存在,因为我已经将该代码作为输入输入一次) ,所以我无法收听该事件。 How can I do that in jQuery? 如何在jQuery中做到这一点?

I solved it using the change event as per the suggestion in comments 我根据评论中的建议使用change事件解决了它

$('#contestCode').on({
            keyup : function(){
                checkContestCodeIfExists($(this));
            },
            paste : function(){
                checkContestCodeIfExists($(this));
            },
            change : function(){
                checkContestCodeIfExists($(this));
            }
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM