我想让两个 RadioButtons 使用相同的 ID,但我想实现这一点,当它被按下时它deposito
显示div1
,当它被按下时它ventanilla
显示div2
. 我看不懂,希望你能帮我用javascript或jquery来做。谢谢
$(document).ready(function() {
$("#pago1").click(function(evento) {
if ("#pago1" == Deposito) {
$("#div1").css("display", "block");
$("#div2").css("display", "none");
} else {
$("#div1").css("display", "none");
$("#div2").css("display", "block");
}
});
});
<p class="auto-style3">
<input name="pago1" type="radio" style="width: 70px; height: 70px" value="Ventanilla" /> <span class="auto-style4"> Recoger en Ventanilla</span>
</p>
<p> </p>
<p class="auto-style3">
<input checked="checked" name="pago1" type="radio" style="width: 70px; height: 70px" value="Deposito" /><span class="auto-style4"> Deposito Bancario</span>
</p>
<p> </p>
<div id="div1" style="display:;">
<p class="auto-style3"><span class="auto-style4">CLABE Bancaria:</span>
</p>
<p class="auto-style1">
<input type="number" name="RECEIVER_BANK_ACCOUNT_NUMBER" id="RECEIVER_BANK_ACCOUNT_NUMBER" size="23" style="font-family: Arial; font-size: 50pt; height: 75px; width: 845px;" required class="auto-style5" />
</p>
<p class="auto-style3"><span class="auto-style4">Confirma CLABE Bancaria:</span>
</p>
<p class="auto-style1">
<input type="number" name="RECEIVER_ACCOUNT_NUMBER_CONFIRMATION" id="RECEIVER_ACCOUNT_NUMBER_CONFIRMATION" size="23" style="font-family: Arial; font-size: 50pt; height: 75px; width: 845px;" required class="auto-style5" />
</p>
</div>
<div id="div2" style="display:none;">
<center>
<span>Has seleccionado ventanilla</span>
</center>
</div>
试试下面的代码
你改变的点
class
以便能够在 jquery 中选择它var valor = $(this).val();
取选定半径的值不需要使用 ID 或类,您可以将事件应用于单选按钮:
请注意,我不是
this
用来指代对象,而是利用event.target
and 效果show()
和hide()
. 我还删除了样式以使其更好地显示。