Javascript 在表单输入之前使用特定类获取div
我有:Javascript 在表单输入之前使用特定类获取div,javascript,jquery,addclass,Javascript,Jquery,Addclass,我有: 警报正在工作,但我无法添加该类。我做错了什么以及如何修复它?不,如果需要语句,只需使用以下命令在选中的输入上执行选择器: if($('.survey_kind_input').is(':checked')){ alert('there is a checked element'); $(this).prev('.survey_kind_choice').addClass('current_choice'); } if($('.survey_kind_input').i
警报正在工作,但我无法添加该类。我做错了什么以及如何修复它?不,如果需要语句,只需使用以下命令在选中的输入上执行选择器:
if($('.survey_kind_input').is(':checked')){
alert('there is a checked element');
$(this).prev('.survey_kind_choice').addClass('current_choice');
}
if($('.survey_kind_input').is(':checked')){
alert('there is a checked element');
$(this).prev('.survey_kind_choice').addClass('current_choice');
}
$('.survey_kind_input:checked').prev('.survey_kind_choice').addClass('current_choice');