I was trying add a checking function according the value
of #input-sample
some if ($('#input-sample').val() <= 0)
or wtsoever.
lets say we had some input value, and some button like below:
<input id="input-sample" value="3"/>
<button class="btn btn-select">SELECT</button>
<button class="btn btn-select">SELECT</button>
<button class="btn btn-select">SELECT</button>
So I just create a function let the btn-select
as able to click to do ajax request.
then
$('.btn-select').click(function(e){
e.preventDefault(); // stop click go to next page
$.ajax({
xxx, xxx, xxx, // some ajax
success: function (response) {
// **** BUT! I just update the '#input-value'
$('#input-sample').val(
parseInt($('#input-sample').val() - 1)
);
});
});
I tried create other kinds of function like
$('#input-sample').change(function(){}); // no luck,
$('#input-sample').on('change', function(){}); // noluck,
$(document).on('change', '#input-sample', function(){}); // same no luck,
Is there any function in javascript / jquery that check the value of the #input-sample
?