jQuery keydown函数不起作用 [英] jQuery keydown function not working
本文介绍了jQuery keydown函数不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在使以下代码正常工作时,我需要一些帮助:
I need some help with making the following code work properly:
$('#entry').keydown(function(e) {
alert(e.keyCode);
});
使用此textarea字段:
With this textarea field:
<textarea id="entry" placeholder="Type message here"></textarea>
我检查了是否在括号之外添加了警报,并且该文档已加载并且可以正常工作.此后,我什至从数据库中提取了一系列条目,没有任何错误.
I have checked with adding alerts outside of the brackets, and the document is loaded and works fine. I even extract a series of entries from a database right after this, with no errors.
我想在这里做的是一个文本字段,当按下Enter键时,它会将字段的.val()
发送到另一个负责AJAX请求的函数.但是很明显,当我无法进入该功能时,我无法到达那里.
What I'm looking to cook here is a textfield that when pressing Enter simply sends the .val()
of the field to another function responsible for the AJAX request. But obviously I can't get there when I cannot enter the function.
推荐答案
$(function() {
$('#entry').on('keyup', function(e) {
if (e.which == 13) someotherFunction(this.value);
});
});
这篇关于jQuery keydown函数不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文