我試圖嵌套一個單選按鈕,如果在if語句中的語句,我不知道我把它放在哪裏。嵌套if語句在jQuery中
我想功能做「如果國家的價值是英國和單選按鈕被選中的話..」
的代碼如下所示。
$('#submit').click (function(){
$.mobile.navigate("#results-page")
if ($("#country").val()==("UK"))
{
$("#important1").text(UK.item1);
$("#important2").text(UK.item2);
$("#important3").text(UK.item3);
}
if ($("#country").val()==("USA"))
{
$("#important1").text(USA.item1);
$("#important2").text(USA.item2);
$("#important3").text(USA.item3);
}
if ($("#country").val()==("France"))
{
$("#important1").text(France.item1);
$("#important2").text(France.item2);
$("#important3").text(France.item3);
}
})
HTML(國家)
<select name="country" id="country">
<option value="UK">UK</option>
<option value="USA">USA</option>
<option value="France">France</option>
</select>
HTML(節假日類型) 露營
<input type="radio" name="radio-choice" id="radio-choice-2" value="choice-2" />
<label for="radio-choice-2">Clubbing</label>
<input type="radio" name="radio-choice" id="radio-choice-3" value="choice-3" />
<label for="radio-choice-3">Luxury</label>
三江源
哪個單選按鈕???然後什麼?您應該提供相關的HTML標記 – 2014-12-04 18:08:58
您應該也可以發佈標記以提供一些上下文 – andrew 2014-12-04 18:10:28
您可以顯示HTML嗎? '#country'是你的單選按鈕嗎? – putvande 2014-12-04 18:10:29