我用一個選擇框:選擇框控件與jQuery
<select name="priority" id="priority">
<option value="4">Low</option>
<option value="3" selected="selected">Normal</option>
<option value="2">High</option>
<option value="1">Emergency</option>
</select>
當用戶選擇「緊急」,然後確認對話框打開,如果用戶確認,被選中,那麼「緊急」。否則應選擇「正常」。爲此,我正在使用jquery:
$(document).ready(function() {
$('#priority').change(function(){
if($(this).val()=='1'){
if(confirm("Are you sure this is emergency?")){
return true;
}
else{
//here some code is needed to select "Normal".
}
}
});
});
現在,我該怎麼做?