Trying to create a simple spinner effect with Jquery, i.e. two buttons (up & down) with a text field. The upbutton increases the value while the down button decreses the value. increment steps + or - 1.
Any suggestions as ui.spinner is most def. not working and I am new to jquery. musty be something like
$(#up).click (function ( /*SOMETHING GOES IN HERE but what?*/ ))
and likewise for #down. both to set adjust the input text field say id #test as above.
Demo: http://jsbin.com/akiki
<button id="inc">+</button>
<button id="dec">-</button>
<input type="text" name="qty" value="0" />
<script type="text/javascript">
$(function(){
$("#inc").click(function(){
$(":text[name='qty']").val( Number($(":text[name='qty']").val()) + 1 );
});
$("#dec").click(function(){
$(":text[name='qty']").val( Number($(":text[name='qty']").val()) - 1 );
});
});
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With