本文介绍了手动触发jQuery的键盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想我已经解决了...请参阅我的评论.抱歉.
我有一个在特定keyup()事件上调用的JSON Web服务,该事件根据输入检索一些数据.我想在输入任何内容之前加载一组初始数据.我正在尝试按照文档中的说明手动调用keyup(),但似乎没有任何作用.
I have a JSON web service that is called on a certain keyup() event which retrieves some data based on the input. I would like to load an initial set of data before anything is typed. I'm trying to manually invoke the keyup() as stated in the documentation, but it doesn't seem to do anything.
$('#inputItemName').keyup(function () {
//perform query, display results
});
在框中输入
^^效果很好
^^ works great when you type in the box
$('#inputItemName').keyup();
^^在文档就绪功能后立即调用,似乎没有任何作用.
^^ called immediately after document ready function, doesn't seem to do anything.
推荐答案
对我来说很好: http://jsfiddle.net/radu /gD5WL/
$('#test').keyup(function () {
console.log('hello');
});
$('#test').keyup();
keyup
事件在页面加载时被调用.
The keyup
event is getting called on page load.
这篇关于手动触发jQuery的键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!