2011-12-07 92 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)); 
    }); 
});