nishanthi nishanthi -3 years ago 80
jQuery Question

How to increment the counter value when the input field is filled?

This is my

view code. Here,I am trying to increment the counter value(ie.,value="0/5") . I have the input fields inside the modal and when clicking on the save button which is inside the model, the value should get incremented based on the filled input

I have tried to increment those counter value.But it displays NaN

var val;
$("input").click(function() {
val = $('#counter').val();
$('#counter').prop('value', val)

<script src=""></script>
<div class="panel-title pull-left">
<i class="fa fa-check-circle" style="font-size:20px;color:lightgreen">
</i> Price,stock and Shipping Information<input type="submit" id="counter" value="0/5" style="background-color: transparent; border:none">

Answer Source
<script type="text/javascript">
    $("input").click(function() {
        let val = parseInt($('#counter').val().split('/')[0]);
        $('#counter').prop('value', `${++val}/5`);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download