获取jQuery keypress事件的输入文本值 [英] Get input text value on jQuery keypress event
本文介绍了获取jQuery keypress事件的输入文本值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
按键后jQuery获取输入值
我'我试图在 jQuery上获得
输入文本
值 .keypress()
功能。我已经看过使用keypress和keydown的各种示例,但并不专注于获取输入值。
有可能吗?
I'm trying to get an input text
value on jQuery
.keypress()
function. I've seen various examples with keypress and keydown, but not dedicated on getting the input value.
Is it possible?
$(document).ready(function(){
$("#my_field").keydown (function (e) {
alert (e);
});
});
返回的对象有一系列属性,但我没有看到值输入字段属性。
The returned object has a series of properties but I haven't seen something for value input field attribute.
有没有办法获得它?
推荐答案
我正在尝试获取输入文本值
I'm trying to get a input text value
使用 val()
:
$("#my_field").keydown (function (e) {
alert ($(this).val());
});
假设 #my_field
是id输入字段,你想得到的值。
Assuming that #my_field
is the id of input field you want to get the value of.
这篇关于获取jQuery keypress事件的输入文本值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文