JSFiddle - React, Tailwind, and code Playground
HTML
<div class="test">
<button onclick="return false;" class="minus"></button>
<input type="text" value="0" size="20" name="" class="input_box">
<button onclick="return false;" class="plus"></button>
</div>
CSS
* {
padding: 0;
margin: 0;
}
.test {
width: 53px;
height: 25px;
float: left;
position: relative;
background-image: url(http://thtml.hol.es/img/namber.png);
background-repeat: no-repeat;
margin: 50px 0 0 50px;
}
.input_box {
width: 34px;
height: 23px;
text-align: center;
border: 0;
color: #000;
margin: 1px 0 0 1px;
float: left;
background-color: transparent;
}
.plus {
width: 15px;
height: 11px;
position: absolute;
border: 0;
top: 0;
right: 0;
background-color: transparent;
background-image: url(http://thtml.hol.es/img/namb_arr_top.png);
background-repeat: no-repeat;
background-position: 4px 4px;
outline: 0;
}
.minus {
width: 15px;
height: 11px;
position: absolute;
border: 0;
right: 0;
bottom: 0;
background-color: transparent;
background-image: url(http://thtml.hol.es/img/namb_arr_bot.png);
background-repeat: no-repeat;
background-position: 4px 2px;
outline: 0;
}
JavaScript
$('.plus').click(function (){
var inp = $(this).parent().find('input[type=text]');
var inp_val = inp.val();
inp_val++;
inp.val(inp_val);
});
$('.minus').click(function (){
var inp = $(this).parent().find('input[type=text]');
var inp_val = inp.val();
inp_val--;
inp.val(inp_val);
if(inp_val < 0){
inp.val( 0 );
}
});