javascript - JQuery get input value -
html
<td data-title="quantity"> <div class="clearfix quantity r_corners d_inline_middle f_size_medium color_dark m_bottom_10"> <button class="btn-minus bg_tr d_block f_left" data-item-price="8000.0" data-direction="down">-</button> <input min="0" class="f_left" type="text" value="2" name="order[line_items_attributes][0][quantity]" id="order_line_items_attributes_0_quantity"> <button class="btn-plus bg_tr d_block f_left" data-item-price="8000.0" data-direction="up">+</button> </div> <div> <a href="#" class="color_dark remove-order"><i class="fa fa-times f_size_medium m_right_5"></i>remove</a><br> </div> </td>
javascript
$('.remove-order').click(function(){ ???? });
how value of input text when remove click?
try closest():
$('.remove-order').on('click', function(e){ alert($(this).closest('td').find('input[name^=order]').eq(0).val()); });
here,
- .closest('td'), nearest parent
td
. - .find('input[name^=order]'), input name attribute starting
order
- .eq(0), first item in list
Comments
Post a Comment