I have a table, in which I have hundreds of rows, and in which each row looks something like this (with different information for each row, of course)
<tr>
<input class="prodId" hidden value="<?php echo $product['id']; ?>">
<td class="thead"><?php echo $product['prod_name']; ?></td>
<td class="thead"><?php echo $product['prod_price']; ?></td>
<td class="thead"><?php echo $product['prod_qty']; ?></td>
<td class="thead">
<select class="availability-options">
</select>
</td>
</tr>
Everything is working well in the option change event of select
. What I'm trying to do is get the value of the id that is in input
. I'm trying this
$(".availability-options").on("change", function(){
let optionSelected = $(this).val();
let _id = $(this).closest("input .prodId").val();
....
And also try this
let _id = $(this).parent().parent().children(".prodId").val();
I understand that both selectors return a Jquery type object, but I can not understand how to obtain the value
of input
. It always returns an indefinite value. How do I get the value of input
?