Javascript 如何使用jQuery隐藏元素?
HTMLJavascript 如何使用jQuery隐藏元素?,javascript,jquery,html,hide,Javascript,Jquery,Html,Hide,HTML <div class="btn-group" data-toggle="buttons"> <label class="btn btn-default active"> <input type="radio" name="payment_options" value=1 autocomplete="off" checked>Cash on Delivery </la
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default active">
<input type="radio" name="payment_options" value=1 autocomplete="off" checked>Cash on Delivery
</label>
<label class="btn btn-default" id="bkash-radio">
<input type="radio" name="payment_options" value=2 autocomplete="off">bKash
</label>
</div>
<input type="hidden" name="trx_id" id="trx_id" class="form-control" placeholder="Enter Transaction ID"/>
当选择第二个单选选项时,我试图显示文本框id=trx_id,但当取消选择时,我希望文本框被隐藏。我该怎么做
[name='payment\u options']
收音机change
事件上,查看this.value==“2”
prop
类型$(document).on(“更改”、“[name='payment\u options']”上的函数(){
$(“#trx_id”).prop(“type”,this.value==“2”?“text”:“hidden”);
});代码>
货到付款
布卡什
您的代码已经在这样做了。不是吗?不是。但是罗科的回答对我有用。谢谢你。解决了我的问题。@Minigunr不客气;)
$(document).on("click", "#bkash-radio", function() {
console.log('test');
$("#trx_id").attr("type", "text");
});
$(document).on("blur", "#bkash-radio", function() {
console.log('test');
$("#trx_id").attr("type", "hidden");
});