如果进行了单选,则为JavaScript隐藏类

问题描述 投票:-3回答:1

你能帮我吗?我有5个广播输入,如果选中了广播,则需要隐藏特定的div。

收音机:交付1交付2交付3交付4交付5

如果检查交付1和5-隐藏.method1如果选中交付2,3,4-隐藏.method2

谢谢!

javascript html hide
1个回答
0
投票

<ul id="shipping_method" class="woocommerce-shipping-methods">
									<li>
						<input type="radio" name="shipping_method[0]" data-index="0" id="shipping_method_0_flexible_shipping_8_6" value="flexible_shipping_8_6" class="shipping_method" checked="checked"><label for="shipping_method_0_flexible_shipping_8_6">Česká pošta - dobírka: <span class="woocommerce-Price-amount amount">120&nbsp;<span class="woocommerce-Price-currencySymbol">Kč</span></span></label>					</li>
									<li>
						<input type="radio" name="shipping_method[0]" data-index="0" id="shipping_method_0_flexible_shipping_6_1" value="flexible_shipping_6_1" class="shipping_method"><label for="shipping_method_0_flexible_shipping_6_1">Platba převodem - doporučeně: <span class="woocommerce-Price-amount amount">80&nbsp;<span class="woocommerce-Price-currencySymbol">Kč</span></span></label>					</li>
									<li>
						<input type="radio" name="shipping_method[0]" data-index="0" id="shipping_method_0_flexible_shipping_6_3" value="flexible_shipping_6_3" class="shipping_method"><label for="shipping_method_0_flexible_shipping_6_3">Platba převodem - doporučené psaní: <span class="woocommerce-Price-amount amount">49&nbsp;<span class="woocommerce-Price-currencySymbol">Kč</span></span></label>					</li>
									<li>
						<input type="radio" name="shipping_method[0]" data-index="0" id="shipping_method_0_flexible_shipping_6_4" value="flexible_shipping_6_4" class="shipping_method"><label for="shipping_method_0_flexible_shipping_6_4">Platba převodem - osobní vyzvednutí v IC Praha (0 Kč)</label>					</li>
									<li>
						<input type="radio" name="shipping_method[0]" data-index="0" id="shipping_method_0_flexible_shipping_7_5" value="flexible_shipping_7_5" class="shipping_method"><label for="shipping_method_0_flexible_shipping_7_5">Platba hotově – osobní vyzvednutí v IC Praha (0 Kč)</label>					</li>
							</ul>

0
投票
if(document.getElementById("delivery1").checked ||document.getElementById("delivery5").checked) {
  document.getElementsByClassName("method1").style.display = "none"
} else {
  document.getElementsByClassName("method2").style.display = "none"
}
热门问题
推荐问题
最新问题