When I click button .one I want .res value to + 1 but it doesnt seem to work
$(".one").click(function(){
$('.res').val() + 1;
})
<input class="res" src="0">
<button class="one">1</button>
You're not saving the value back into $('.res'). Also note that you need to use parseInt (or possibly parseFloat) to convert the string value to a number, and you should set the initial value of $('.res') with value, not src:
$(".one").click(function(){
$('.res').val(parseInt($('.res').val()) + 1);
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input class="res" value="0">
<button class="one">1</button>
You're giving the <input> tag a src of 0 when it should be value:
<input class="res" value="0">
The jQuery is also syntactically incorrect, consider this instead:
var counter = $(".res").val();
$(".one").click(function(){
counter++;
$(".res").val(counter);
});
disabled="disabled" or readonly="readonly" in the HTML.
.valgets the value - don't think the src attribute is valid for an input (unless it is an image input)inputshould havevalue="0", notsrc="0"