A jQUery object behaves like an array of DOM elements.
Therefore, inputs[0]
returns the raw DOM element, not a jQuery wrapper.
Since raw DOM elements do not have a val()
method, you're getting an error.
To call jQuery methods on a specific element, you should call the eq()
method, like this:
inputs.eq(0).val();
In your case, you can also simply get the value
property from the raw DOM element, like this:
inputs[0].value
Note, however, that this will not behave like jQuery's val()
for <select>
elements.