2011-12-07 94 views

回答

1

为什么你不只是做parent().find()

$(document).ready(function(){   
    $('.this_payment').live('change keyup',function() { 
     $(this).parent().find('.trans-selected').prop("checked", ($(this).val() > 0)); 
    }); 
}); 
0

尝试以下操作:

$(document).ready(function(){   
    $('.this_payment').keyup(function() { 
     $(this).prev('.trans-selected').prop("checked", ($(this).val() > 0)); 
    }); 
}); 

See here for updated jsFiddle.

0

试试这里的工作代码js fiddle,你可以使用prev(),而不是closest()

+0

这个例子不检查我 –

+0

它为我工作的复选框,我改变了第一场到5的值,该复选框选中得到,同样地,我改变了第二场8和同结果 –

+0

奇怪。在Chrome(15.0.874.121) –

0

试试这个

$(document).ready(function(){   
    $('.this_payment').live('change keyup',function() { 
     $(this).parent().find('.trans-selected').prop("checked", ($(this).val() > 0)); 
    }); 
});