Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如果选中/选中所有2维单选按钮,则启用按钮_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript 如果选中/选中所有2维单选按钮,则启用按钮

Javascript 如果选中/选中所有2维单选按钮,则启用按钮,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我想制作一些表格,给每个选项打分,一个值不能是相同的值,我已经用二维单选按钮做了,下一个问题是,如果没有对所有选项进行排序,用户就不能进入下一列,如果只有一个单选按钮通过javascriptdocument on change选中,我可以做下一列,所以我有这个想法 $(document).on('change', '.answer1', function(){ $(document).on('change', '.answer2', function(){ $(document).on('cha

我想制作一些表格,给每个选项打分,一个值不能是相同的值,我已经用二维单选按钮做了,下一个问题是,如果没有对所有选项进行排序,用户就不能进入下一列,如果只有一个单选按钮通过
javascript
document on change选中,我可以做下一列,所以我有这个想法

$(document).on('change', '.answer1', function(){
$(document).on('change', '.answer2', function(){
$(document).on('change', '.answer3', function(){
$(document).on('change', '.answer4', function(){
$(this).closest('.cont').find('.next').removeAttr("disabled");
有时它的工作,但有时它没有,可以

$('.cont').addClass('hide');
计数=$('.questions')。长度;
$('#问题'+1).removeClass('hide');
$(文档).on('click','next',函数(){
last=parseInt($(this.attr('id'));
nex=最后一次+1;
$('#问题'+last).addClass('hide');
$('#问题'+nex).removeClass('hide');
控制台日志(nex);
});
$(文档).on('单击','.previous',函数(){
last=parseInt($(this.attr('id'));
pre=last-1;
$('#问题'+last).addClass('hide');
$('#问题'+pre).removeClass('hide');
});
$(文档).on('change','answer1',function(){
$(document).on('change','answer2',function(){
$(文档).on('change','answer3',function(){
$(document).on('change','answer4',function(){
$(this).closest('.cont').find('.next').removeAttr(“已禁用”);
})
})
})
});
表格{
边界塌陷:塌陷;
}
运输署,
th{
边框:1px实心#ccc;
填充:10px;
}
空的{
边界:0;
}

$(函数(){
var-col,el;
$(“输入[type=radio]”。单击(函数(){
el=$(本);
col=高程数据(“col”);
$(“输入[data col=“+col+”]”)prop(“选中”,false);
el.道具(“已检查”,正确);
});
});
1.
2.
3.
4.
选择1
选择2
选择3
选择4
下一个

您可以添加条件来检查总检查单选按钮,如下所示

$("input[type=radio]").click(function() {
    el = $(this);
    col = el.data("col");
    $("input[data-col=" + col + "]").prop("checked", false);
    el.prop("checked", true);
    if($("input[data-col]:checked").length == 4){
        $("button").prop('disabled',false);
    }else{
        $("button").prop('disabled',true);
    }
  });

我希望它能帮助你。(我直接使用了按钮,这可能与页面上的outher按钮冲突)。

您可以添加条件来检查全部选中的单选按钮,如下所示

$("input[type=radio]").click(function() {
    el = $(this);
    col = el.data("col");
    $("input[data-col=" + col + "]").prop("checked", false);
    el.prop("checked", true);
    if($("input[data-col]:checked").length == 4){
        $("button").prop('disabled',false);
    }else{
        $("button").prop('disabled',true);
    }
  });

我希望它能帮助你。(我直接使用了按钮,这可能会与页面上的outher按钮冲突)。

您能批准我的编辑超过一列吗?谢谢你的回复,它成功了:)你能批准我的编辑超过一列吗?谢谢你的回答,它成功了:)