不带onclick的选中单选按钮上的JQUERY警报

不带onclick的选中单选按钮上的JQUERY警报,jquery,Jquery,我不想用onclick。当单选按钮被选中时,我正试图正确使用和if-else语句,但我一定是做错了什么,因为即使我下面的简单测试也不起作用 正确的解决方案是什么 function test() { if (jQuery("#vendor-date-method-checkbox").prop("checked")) { alert('yes'); }else{ alert('no') }; }; <input type="radi

我不想用onclick。当单选按钮被选中时,我正试图正确使用和if-else语句,但我一定是做错了什么,因为即使我下面的简单测试也不起作用

正确的解决方案是什么

function test() {
if (jQuery("#vendor-date-method-checkbox").prop("checked")) {
alert('yes');
}else{
alert('no')
};
};   


<input type="radio" id="vendor-date-method-checkbox2" name="vendor-method-checkbox2" value="vendor-date-method-checkbox" autocomplete="off" disabled>
<label for="vendor-date-method-checkbox2">Date Method
</label>
<br>
<input type="radio" id="vendor-custom-method-checkbox2" name="vendor-method-checkbox2" value="vendor-custom-method-checkbox" autocomplete="off" disabled>
<label for="vendor-custom-method-checkbox2">Custom Input Method
</label>
<br>
<input type="date" id="deposit-due2" name="deposit-due" maxlength="2" size="4" class="deposit-input" autocomplete="off" placeholder="ie 'upon '" disabled>
功能测试(){
if(jQuery(“#供应商日期方法复选框”).prop(“选中”){
警惕(“是”);
}否则{
警报('否')
};
};   
日期法

自定义输入法
您没有调用测试

功能测试(事件){
var target=event.target;
if(target.checked){
警惕(“是”);
}否则{
警报('否')
};
};
//调用你的函数
jQuery(“#vendor-date-method-checkbox2”)。单击(函数(事件){
测试(事件);
});
jQuery(“#vendor-custom-method-checkbox2”)。单击(函数(事件){
测试(事件);
});

日期法

自定义输入法

谢谢。在页面加载时,现在显示“是”警报,但当我在两个单选按钮之间切换时,什么也没有发生,也没有更多警报?您的输入被禁用。删除禁用的属性。您想让我将其添加到代码中吗?您的查询错了。@Manny我更新了代码。你想怎么做就怎么做。