Javascript 防止在不使用onclick函数的情况下使用jquery检查单选按钮
我想在我下面的代码中阻止选中单选按钮,当Javascript 防止在不使用onclick函数的情况下使用jquery检查单选按钮,javascript,jquery,Javascript,Jquery,我想在我下面的代码中阻止选中单选按钮,当Pinterest==1&&value==“video”时。我找到了阻止选中单选按钮的代码,但该代码在按钮的单击事件中起作用。我想阻止单选按钮 正在检查而没有onclick事件 if(Pinterest==1 && value=="video"){ alert("You can not upload the video in Pinterest."); /* $('#video_type_radio').click(func
Pinterest==1&&value==“video”
时。我找到了阻止选中单选按钮的代码,但该代码在按钮的单击事件中起作用。我想阻止单选按钮正在检查而没有onclick事件
if(Pinterest==1 && value=="video"){
alert("You can not upload the video in Pinterest.");
/* $('#video_type_radio').click(function(e){
e.preventDefault();
}); */
//Here I want to prevent the radio button being checked
}
//Radio button code
<input name="group5" type="radio" id="video_type_radio" class="with-gap radio-col-black" value="video" onchange="checkPost()" >
<label for="video_type_radio" style="margin-left:30px;">Post With Single Video</label>
if(Pinterest==1&&value==video){
警报(“您无法在Pinterest中上载视频。”);
/*$(“#视频_类型_收音机”)。单击(功能(e){
e、 预防默认值();
}); */
//这里我想防止单选按钮被检查
}
//单选按钮代码
用单个视频发布
您可以使用直接禁用单选按钮
if(Pinterest==1 && value=="video"){
alert("You can not upload the video in Pinterest.");
$("#video_type_radio").attr('disabled', true);
}
else
{
$("#video_type_radio").attr('disabled', false);
}
这将禁止选中单选按钮。您可以执行以下操作
if(Pinterest==1 && value=="video"){
alert("You can not upload the video in Pinterest.");
//Here I want to prevent the radio button being checked
$("#video_type_radio").attr('disabled', true);
}
else{
$("#video_type_radio").attr('disabled', false);
}
请提供一个链接,以便基本上不使用onclick事件来阻止单选按钮被选中?您的问题不清楚。一个离题:@SBylemans供将来参考,您可以使用
[mcve]
生成指向的链接。ye我想阻止单选按钮在不使用onclick事件@code\u ninja的情况下被选中