[英]Disable checkbox on radio button click
我有2个单选按钮,并且如果单击单选按钮,则想禁用array
复选框。 这是.net
一篇文章的一些代码。
我使用ASP
classic,并且希望能帮助您修改此代码或最能实现我的目标的代码。
<input type="radio" name="group" value="value1">
<input type="radio" name="group" value="value2">
This is the checkbox that is in the loop for the array:
<input type="checkbox" name="items" value="<%=Rs("item") %>">
$(document).ready(function () {
$('#<%= rbRadioButton.ClientID %> input').change(function () {
// The one that fires the event is always the
// checked one; you don't need to test for this
alert($(this).val());
});
});
如何使用.prop()
方法。
// Disable checkbox $("input[value='value1']").change(function() { $("input[name='items']").prop('disabled', true); }); // Enable checkbox $("input[value='value2']").change(function() { $("input[name='items']").prop('disabled', false); }); // Trigger reset button click $("#btnReset").on("click", function() { $("input[name='group']").prop('checked', false); $("input[name='items']").prop('checked', false); $("input[name='items']").prop('disabled', false); });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script> <fieldset> <legend>radio:</legend> <input type="radio" name="group" value="value1">disabled <input type="radio" name="group" value="value2">enabled </fieldset> <fieldset> <legend>checkbox:</legend> <input type="checkbox" name="items" value="1"> <input type="checkbox" name="items" value="2"> <input type="checkbox" name="items" value="3"> <input type="checkbox" name="items" value="4"> <input type="checkbox" name="items" value="5"> </fieldset> <input type="button" value="Reset" id="btnReset">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.