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.
Works for me with 1.6.2: http://jsbin.com/itidav/edit#javascript,html