我试图嵌套一个单选按钮,如果在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