Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
103
rated 0 times [  107] [ 4]  / answers: 1 / hits: 59562  / 14 Years ago, sat, august 7, 2010, 12:00:00

Possible Duplicate:

jQuery get input value after keypress






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.



Is there some way to get it?


More From » jquery

 Answers
30

I'm trying to get a input text value




Use the val():



$(#my_field).keydown (function (e) {
alert ($(this).val());
});


Assuming that #my_field is the id of input field you want to get the value of.


[#95996] Wednesday, August 4, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
yesseniadajab

Total Points: 258
Total Questions: 101
Total Answers: 127

Location: Mexico
Member since Mon, Sep 12, 2022
2 Years ago
yesseniadajab questions
Tue, Aug 3, 21, 00:00, 3 Years ago
Fri, Jan 15, 21, 00:00, 3 Years ago
Thu, Dec 10, 20, 00:00, 4 Years ago
;