【发布时间】:2014-02-14 21:24:49
【问题描述】:
<label for="continent">Select Continent</label>
<select id="continent" onchange="countryChange(this );">
<option value="empty">Select a Continent</option>
<option value="North America">North America</option>
<option value="South America">South America</option>
<option value="Asia">Asia</option>
<option value="Europe">Europe</option>
<option value="Africa">Africa</option>
</select>
<br/>
<label for="country">Select a country</label>
<select id="country">
<option value="0">Select a country</option>
</select>
<div id="soc-pri">
<label for="company">Company</label>
<input name="customer" type="radio" value="company" />
<label for="private">Private</label>
<input name="customer" type="radio" value="private" />
</div>
<div id="lib-ass">
<label for="individual firm / freelancer">Individual Firm / Freelancer Professionista</label>
<input name="customer" type="radio" value="privato" />
<label for="association">Associazione</label>
<input name="customer" type="radio" value="association" />
</div>
$(document).ready(function () {
$("select").change(function () {
if ($("select option:selected").val() == "Europe") {
$('#lib-ass').show();
$('#soc-pri').show();
} else if ($("select option:selected").val() != "Europe") {
$('#lib-ass').hide();
}
}).change();
});
大家好,我刚开始学习jquery。 我有两个包含大陆和国家的选择字段。
我需要 nascodere 显示两个 DIV,“lib-ass”和“soc-first”:
1) 当您选择欧洲大陆时,会出现 DIV“lib-ass”。 没关系
2) 当你没有选择欧洲大陆 DIV “lib-ass”时,隐藏。 没关系
3 当您不选择国家 DIV British 时,“lib-ass”必须隐藏。 这样不行。
当您选择国家 DIV British 时,您必须显示“lib-ass”。 这样不行
我的问题是我不能隐藏显示,当你选择你的国家英国时,ID为“lib-ass”的DIV标签。
我哪里错了?
我希望 averdato 提供尽可能多的信息。 谢谢
【问题讨论】:
-
My needs nascodere是什么意思? -
你要this
-
抱歉英语不好
-
我想写hide,对不起
-
@Satpal 是我设法做到的
标签: javascript jquery html select show-hide