Answers for "js increment and decrement function for cart"

0

js increment and decrement function for cart

<div class="container">
<input type="button" onclick="decrementValue()" value="-" />
<input type="text" name="quantity" value="1" maxlength="2" max="10" size="1" id="number" />
<input type="button" onclick="incrementValue()" value="+" />
</div>
Posted by: Guest on September-11-2021
0

js increment and decrement function for cart

<script type="text/javascript">
function incrementValue()
{
    var value = parseInt(document.getElementById('number').value, 10);
    value = isNaN(value) ? 0 : value;
    if(value<10){
        value++;
            document.getElementById('number').value = value;
    }
}
function decrementValue()
{
    var value = parseInt(document.getElementById('number').value, 10);
    value = isNaN(value) ? 0 : value;
    if(value>1){
        value--;
            document.getElementById('number').value = value;
    }

}
</script>
Posted by: Guest on September-11-2021

Code answers related to "js increment and decrement function for cart"

Code answers related to "Javascript"

Browse Popular Code Answers by Language