Hello. There was such a simple little problem, but for some reason it does not go out to finish it properly. It is necessary to embed the number of materials on a page where you can not edit the html code. The choice of values itself looks like this:
(function ($) { $('.spinner').each(function() { var spinner = $(this), input = spinner.find('input[type="text"]'), btnUp = spinner.find('.up'), btnDown = spinner.find('.down'), // options step = 1, min = 1, max = 100; input.val(min); btnUp.click(function(){ input.val() >= max ? $(this).prop("disabled",true) : input.val((input.val()*1) + step); }); btnDown.click(function(){ input.val() <= min ? $(this).prop("disabled",true) : input.val((input.val()*1) - step); }); }); })(jQuery); .spinner { width: 100px; height: 50px; display: table; margin-bottom: 30px; } .spinner input[type="text"] { border-top-left-radius: 3px; border-bottom-left-radius: 3px; width: 50px; text-align: center; height: 50px; float: left; border: 1px solid #ccc; border-right: none; } .spinner .nav { float: left; } .spinner .nav .up, .spinner .nav .down { cursor: pointer; border: 1px solid #ccc; width: 25px; height: 25px; text-align: center; line-height: 25px; background-color: #ddd; color: #333; font-size: 20px; } .spinner .nav .up:hover, .spinner .nav .down:hover { box-shadow: inset 0px 0px 17px 0px rgba(255, 255, 255, 0.5); } .spinner .nav .up { border-top-right-radius: 3px; } .content .container .spinner .nav .down { border-bottom-right-radius: 3px; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="spinner"> <input type="text"> <div class="nav"> <div class="up">+</div> <div class="down">-</div> </div> </div> <div class="spinner"><input name="cnt_10" maxlength="5" size="5" value="1" type="text"></div> <div class="spinner"><input name="cnt_11" maxlength="5" size="5" value="1" type="text"></div> There is also an example of a code with inputs, to which you need to add the + and - buttons. I tried using .append to create a structure before performing the function inside the block with inputs, but the switch stops working. If necessary, I will add my code, but, given that it does not work, there is not much sense from this. I would be grateful for an example or at least a line of thought.