「daypattern」というラジオボタン セットがあります。それをクリックすると、チェックされたメンバーのフォームフィールドの兄弟が有効になり、他のメンバーのフォームフィールドの兄弟 (存在する場合) が無効になります。チェックされたフィールドの値を現在のラジオ ボタンの値と比較しようとしていますが、チェックされたフィールドの値は、ラジオ ボタンの値属性から期待される文字列ではなく整数を返します。
この番号はどこで入手できますか?どうすれば修正できますか?より良いアプローチはありますか?
ありがとう
問題関数:
$.fn.setActiveState=function(){
var c=$(this+':checked').val();//c=3 instead of 'everyday' OR 'everywday'. WHY?
this.each(function(){
alert(c + ' and '+ $(this).val());//3 and 'everyday' OR 'everywday'
if($(this).val()== c){
$(this).siblings(':input').removeAttr("disabled");
}else{
$(this).siblings(':input').attr('disabled',true);
}
});
}
HTML
<label>
<input type='radio' name='daypattern' value='everyday' checked='checked'/>Every
<input type='text'class='numtext' name='day_increment' value='1'/> day(s)
</label>
<label>
<input type='radio' name='daypattern' value='everywday'/>Every weekday
</label>
で問題関数を呼び出します$(document).ready
:
$("input[name='daypattern']").setActiveState();