使用下面的代码,当我单击并按住bid-up
按钮时,它只通过一次代码,我必须再次单击它才能工作。它应该做的是重复代码直到 mouseup 或 mouseleave。我做错了什么?
$('.bid-up').live('mousedown',function() {
var button = $(this);
timeoutId = setTimeout(function(){
var number = button.parent('div').siblings('#bid-child-container-2').find('#bid-price').val();
var newnumber = number.split('.');
var on = button.attr('data-on');
button.siblings('#bid-down').attr('data-on','1');
if(newnumber[1]<9) {
var first = newnumber[0];
var second = parseInt(newnumber[1])+1;
}
if(newnumber[1]==9) {
var first = parseInt(newnumber[0])+1;
var second = 0;
}
var finalnumber = first+'.'+second;
button.parent('div').siblings('#bid-child-container-2').find('#bid-price').val(finalnumber);
}, 20);
}).bind('mouseup mouseleave', function() {
clearTimeout(timeoutId);
});