i have got html :
<div class="kusy"><input value="{{ $array['summary'] }}" type="text" onchange="$(this).closest('form').submit(); return false;" onkeypress='return event.charcode >= 48 && event.charcode <= 57' class="kusy-input" name="summary"></div> <div class="plus-minus"> <input type="hidden" name="_token" value="{{ csrf_token() }}" /> <input type="hidden" name="id" value="{{ $product->id }}" /> <input type="hidden" name="action" value="edit-summary" /> <input class="klik-plus" type="submit" value="+"> <input class="klik-minus" type="submit" value="-"> </div>
and javascript :
$(document).ready(function(){ $('.klik-plus').click(function(){ alert($(this).closest('.kusy-input').val()); }); });
when click on plus button, shows me alert message "undefined", in value of inputbox number 4.
how can value?
closest in ancestors , siblings of elements, can't reach kusy-input.
what reach parent element , find input
$(document).ready(function(){ $('.klik-plus').click(function(){ alert($(this).parents().find('.kusy-input').val()); }); });
Comments
Post a Comment