Home » Jquery » javascript – Change Input Value Jquery-Exceptionshub

javascript – Change Input Value Jquery-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment

Questions:

Please help me, I want the value to change if I change the value in the text box . please see the picture enter image description here

this is my code :

$(document).ready(function () {
	//Stop people from typing
	$('.spinner-1 input').keydown(function (e) {
		e.preventDefault();
		return false;
	});
	var minNumber = 1;
	var maxNumber = 10;

	$('.spinner-1 .btn:first-of-type').on('click', function () {
		if ($('.spinner-1 input').val() == maxNumber) {
			return false;
		} else {
			$('.spinner-1 input').val(parseInt($('.spinner-1 input').val(), 10) + 1);
		}
	});

	$('.spinner-1 .btn:last-of-type').on('click', function () {
		if ($('.spinner-1 input').val() == minNumber) {
			return false;
		} else {
			$('.spinner-1 input').val(parseInt($('.spinner-1 input').val(), 10) - 1);
		}
	});
});
<div class="input-group spinner-1">
                            <div class="input-group-prepend">
                            <button class="btn" style="background-color:#3b5998; color:white;" type="button">
                                <i class="fas fa-walking"></i>
                            </button>
                            </div>
                            <input type="text" class="form-control" value="1">
                                <div class="input-group-btn-vertical">
                                    <div id="other" class="btn btn-success"><i class="fas fa-plus fa-sm"></i></div>
                                    <div class="btn btn-danger"><i class="fas fa-minus fa-sm"></i></div>
                                </div>
                        </div>
How to&Answer: