Jquery cannot get value from each function -
i using tables input fields in them. trying value set of input fields same class , compare each of adjacent input diffrent class name. can see value in input value returned empty jquery.
$('.subtotal').each(function(){ var price = $(this).parent().parent().find('td input.price'); console.log(price.val()); });
here html. these rows repeated.
<tr> <td> <input type="text" name="data[<?=$i?>][title]" class="title"/> <ul class="order_search_title"> </ul> </td> <td> <input type="text" name="data[<?=$i?>][author]" class="author"/> </td> <td> <input type="text" name="data[<?=$i?>][isbn]" class="isbn"/> <ul></ul> </td> <td> <select hidden="hidden" name="data[<?=$i?>][qty]" id="" class="qty"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> </td> <td> <input type="number" name="data[<?=$i?>][price]" class="price" readonly /> </td> <td> <input type="number" name="data[<?=$i?>][subtotal]" class="subtotal" readonly/> </td> <td> <a href="#" class="cleartext">clear</a> </td> <td> <img class="delete" src="<?=base_url()?>/imgs/delete25.png" /> </td> </tr>
you're using incorrect variable. use price instead of pr
$('.subtotal').each(function(){ var price = $(this).parent().parent().find('td input.price'); console.log(price.val()); //this should price not pr });
Comments
Post a Comment