我有這方面的投入和複選框的形式jQuery的複選框被選中需要輸入條目
<input class="validate[minCheckbox[1]] checkbox" id="maxcheck_0" type="checkbox" name="children[]" value="Juliette" />
<input type="text" name="school[]" id="school_0" value="" /><br />
<input class="validate[minCheckbox[1]] checkbox" id="maxcheck_1" type="checkbox" name="children[]" value="Franck" />
<input type="text" name="school[]" id="school_1" value="" /><br />
<input class="validate[minCheckbox[1]] checkbox" id="maxcheck_2" type="checkbox" name="children[]" value="Lisa" />
<input type="text" name="school[]" id="school_2" value="" />
與這個jQuery綁定的複選框,點擊
$('input[type=checkbox]').bind('click',function() {
if($(this).is(':checked')){
$('#school_0').attr('class', 'validate[required]');
//$('#school_1').attr('class', 'validate[required]');
//$('#school_2').attr('class', 'validate[required]');
} else {
$('#school_0').removeAttr('class');
//$('#school_1').removeAttr('class');
//$('#school_2').removeAttr('class');
}
});
我怎麼能一個類屬性添加到任何與其複選框相關的輸入?
定義*有關*? – arnaud576875
對不起,我的英語不太好!相關=相關聯(第一個複選框與第一個輸入,第二個複選框與第二個輸入,... – Chris