这是我需要实现的。有一个多重选择,其中包含2个值,“ Home”和“ Rent”。我需要在选择“主页”时显示另一个多重选择,以及在同时选择“主页”和“出租”时显示相同的选择。我有点卡住了。这是我的HTML和JS。我知道这是因为当您选择两个值时,JS只是认为存在一个值,因此无法正常工作。还应该在页面加载时隐藏多选选择,这是它的工作,但是它需要显示是否保存并选择了该值并重新加载了页面。谢谢。
<select name="oie_string_multiselect_home_ownership" id="am_oie_string_multiselect_home_ownership">
<option value="Home">Home</option>
<option value="Rent">Rent</option>
</select>
//Select that is supposed to show or hide.
<select name="oie_string_multiselect_home_value"id="am_oie_string_multiselect_home_value">
<option value = "1000.00"></option>
</select>
//JS
var $homeOwnership = $('#oie_string_multiselect_home_ownership');
var $homeOwnershipOption = $('#oie_string_multiselect_home_ownership option')
var $homeOwnershipValueMultiselect = $('#oie_string_multiselect_home_value');
$homeOwnershipValueMultiselect.hide();
$($homeOwnershipOption).click(function() {
var value= $(this).attr('value');
if (value == "Home") {
$homeOwnershipValueMultiselect.show();
}
else if (value == "Home" && value == "Rent") {
$homeOwnershipValueMultiselect.hide();
}
else {
$homeOwnershipValueMultiselect.hide();
}