I'm trying to get the value of an form input, which is inside a table cell, but it is getting returned as undefined.
$('.js-form').submit(function(event) {
alert($(this).children().has("input[name='points']").val());
});
My HTML is as follows:
<tr>
<form action='...' method='post' class='js-form'>
<td><input type='text' name='points'/></td>
</form>
</tr>
There are multiple of these forms on the same page, I'm under the impression that using $(this) will restrict my DOM traversal to the selected form that the function is currently handling, but not sure why I don't get any value back? (there is a value in the field)
tdelement. Have a look at the documentation: api.jquery.com/has. However, your HTML is invalid and the browser might actually render a totally different DOM (e.g. move the form out of the row).input[nqme='points']which would explain why OP is seeking from the form itself.