I am trying to create an object of type spinner like jQuery earlier, today someone gave me this code, which increases the value of the text field up / down when the button is clicked. Fantasy. But what do you do to disable the .desc button, if the value is 0 - zero. In PHP it is very easy, if if <= 0, then this, etc., but I don’t know jQuery ..
Also any ideas on how it can be used to move up / down the html unordered list, i.e. ul li?
$(document).ready(function()
{
$(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);
});
});
});
The form is used here:
<input type="text" name="qty" value="0" />
<img src="img/up.png" class="inc" width="20px" height="9px" alt="Increase" title="increase" />
<img src="img/down.png" class="dec" width="20px" height="9px" alt="Decrease" title="Decrease" />
source
share