Why does this increment/decrement code work with jquery 1.3 and not with 1.6?

175 Views Asked by At

This code allows me to change the value of a number box on a form using jquery. It works with 1.3 but not with 1.6. Can anyone explain why?

$(function() {

$("form div").append('<div class="inc button">+</div><div class="dec button">-</div>');

$(".button").click(function() {
    var $button = $(this);
    var oldValue = $button.parent().find("input").val();

if ($button.text() == "+") {
    var newVal = parseFloat(oldValue) + 1;
} else {
if (oldValue >= 1) 
    {
        var newVal = parseFloat(oldValue) - 1;
    }
}
    $button.parent().find("input").val(newVal);
});
});

Code is from the tutorial here.

1

There are 1 best solutions below

0
On