你好,我需要幫助,這是我的代碼,它總是去其他條件 如果值和文本匹配,我想要comapre下拉文本然後我想隱藏一些div:IF語句不適用於jquery
jQuery("#myid").on('change', function() {
if(jQuery('#myid').val() == 'Well, this is a dummy text') {
alert(" hello");
} else {
alert("World");
}
});
<select name="testtype" id="myid" class="validate[required]" style="font-size:12px; font-family:arial">
<option selected="selected" value="">-- Make your selection --</option>
<option id="first" value="Health, Safety and Environment Test for Operatives ">Health, Safety and Environment Test for Operatives </option>
<option value="Supervisory-English only">Supervisory-English only</option>
<option value="Health, Safety and Environment Test for Managers and Professionals -English only">Health, Safety and Environment Test for Managers and Professionals -English only</option>
<option value="Demolition-English only">Demolition-English only</option>
<option value="Highway Works-English only">Highway Works-English only</option>
<option value="Specialist Work at Hight-English only">Specialist Work at Hight-English only</option>
<option value="Lifts and Escalators-English only">Lifts and Escalators-English only</option>
<option value="Tunnelling-English only">Tunnelling-English only</option>
<option value="Heating, Ventilation Air Conditioning and Refrigeration (HAVCR)-English only">Heating, Ventilation Air Conditioning and Refrigeration (HAVCR)-English only</option>
<option value="Plumbing (JIB)-English only">Plumbing (JIB)-English only</option>
</select>
你怎麼能指望任何人幫助與失敗的原因在?只有你可以知道'jQuery('#myid')。val()'是什麼,因此條件失敗。 – str
向我們展示Html代碼! –
什麼元素屬於#myid –