JSFiddle - React, Tailwind, and code Playground
by this_mong
HTML
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<div class="number">
<a href="#" id="increaseQuantity">수량 올림</a>
<span id="numberUpDown">1</span>
<a href="#" id="decreaseQuantity">수량 내림</a>
</div>
JavaScript
$(function(){
$('#decreaseQuantity').click(function(e){
e.preventDefault();
var stat = $('#numberUpDown').text();
var num = parseInt(stat,10);
num--;
if(num<=0){
alert('더이상 줄일수 없습니다.');
num =1;
}
$('#numberUpDown').text(num);
});
$('#increaseQuantity').click(function(e){
e.preventDefault();
var stat = $('#numberUpDown').text();
var num = parseInt(stat,10);
num++;
if(num>5){
alert('더이상 늘릴수 없습니다.');
num=5;
}
$('#numberUpDown').text(num);
});
});