So I get a set of form elements that I want to extract the values from, by using
var inputs = $("input.row_2");
inputs[0].val()
When I run this, I get told that val is not a valid method.
What am I doing wrong?
Should be an easy one..
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
inputs[0]returns you the DOM element, soinputs[0].valuewill have what you want.You can also use
inputs.eq(0).val()which will never complain thatinputs[0]is undefined if there are no matches..eq()returns a jQuery object (not DOM) as opposed to.get()which is also what you will get from using[0]