JSFiddle - React, Tailwind, and code Playground
by magicalex
HTML
<input type="text" id="spinner" size="1" value="0">
<label for="spinner">
<span class="up">▴</span>
<span>▾</span>
</label>
CSS
#spinner {
font-size: 24px;
float:left;
height: 31px;
}
label {
float:left;
height:30px;
color: #444;
}
span {
font-size:15px;
line-height: 15px;
height: 15px;
width:20px;
display: block;
cursor:pointer;
text-align:center;
border: 1px solid #ccc;
border-bottom-color:#aaa;
border-top-color: #eee;
background-color: #ddd;
}
span:hover {
color: #777;
background-color: #eee;
}
JavaScript
var timer,
value = 0;
$('span').mousedown(function(){
var increment = $(this).is(':first-of-type') ? 1 : -1;
value=value+increment;
$('input').val(value);
timer = setInterval(function(){
value=value+increment;
$('input').val(value);
}, 200);
}).mouseup(function(){
clearInterval(timer);
});