i have two check boxes, when one check box is clicked then the other one must be enable otherwise it should be disabled (both check box and text)
HAML code:
%label.checkbox
= check_box_tag 'Name'
Name
%label.checkbox
= check_box_tag 'Description'
Description
You can just use a little jQuery:
HTML:
<input type="checkbox" class="enabler" />
<input type="checkbox" class="optional" disabled />
<input type="checkbox" class="optional" disabled />
JS:
$(".enabler").on("change", function(e) {
$(".optional").prop("disabled", !$(this).prop("checked"));
});
嗯,听起来您想使单选按钮可以提供的功能过于复杂
HTML
<input type="checkbox" onclick="func();" />
<input type="checkbox" id="dis" disabled="disable" />
JQuery
function func(){
var optObj = $("checkbox#dis");
if(optObj.attr("disabled"))
optObj.removeAttr("disabled");
else
optObj.attr("disabled", "disable");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.