gpt4 book ai didi

javascript - 防止使用 jquery 在不使用 onclick 函数的情况下检查单选按钮

转载 作者:行者123 更新时间:2023-12-03 01:25:47 25 4
gpt4 key购买 nike

我想防止在下面的代码中 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"){
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);
}

关于javascript - 防止使用 jquery 在不使用 onclick 函数的情况下检查单选按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51554038/

25 4 0
文章推荐: javascript - ASP.NET:使用 Ajax (JSON) 从 View 到 Controller POST List/Model