我有一個webform有幾個選項。如果某人選擇某個選項,則包含更多詳細信息的div將淡入以顯示信息。問題是當選擇選項的div不會淡入。我有類似的代碼在窗體的另一部分,它工作正常。我不確定我錯了什麼。基於選擇的選項淡入div
下面是代碼:
FORM HTML
<label for="CAT_Custom_265083_93822">If completing the training through your workplace, Recruitment Agency or JSA - please provide their details: </label>
<select name="CAT_Custom_265083_93822 employer-ra-jsa" id="CAT_Custom_265083_93822" class="cat_dropdown">
<option value=" ">-- Please select --</option>
<option value="Employer">Employer</option>
<option value="Recruitment Agency">Recruitment Agency</option>
<option value="JSA">JSA</option>
<option value="Not Applicable">Not Applicable</option>
</select>
<div class="employer-jsa">
<!-- CODE TO FADE IN -->
</div>
JS FOR FORM
$(function() {
$('.employer-jsa').hide();
$('.employer-ra-jsa').change(function() {
if ($('.employer-ra-jsa option:selected').text() == "Employer"){
$('.employer-jsa').fadeIn("slow");
}
else if ($('.employer-ra-jsa option:selected').text() == "Recruitment-Agency"){
$('.employer-jsa').fadeIn("slow");
}
else if ($('.employer-ra-jsa option:selected').text() == "JSA"){
$('.employer-jsa').fadeIn("slow");
}
else {
$('.employer-jsa').fadeOut("slow");
}
});
});
我有什麼錯我的代碼?沒有錯誤拋出,div只是不褪色。
注意:我正在使用jQuery 1.8.3。
我想我一直在尋找長期的代碼。簡單的錯誤。謝謝您的幫助。 – L84