gpt4 book ai didi

javascript - 单选按钮组

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

我有一个单选按钮组,我尝试在选中 5 个单选按钮时显示按钮,但我不能这样做。这是我的代码:

$(document).ready(function () {
$('#vote_submit_button').hide();
var unanswered = new Array();
$('table').each(function () {
var question = $(this).find('input').attr('name');
if (!$(this).find('input').is(':checked')) {
unanswered.push(question);
}
});

if (unanswered.length > 0) {
} else {
$('#vote_submit_button').show();
}
});

请帮忙)

最佳答案

您的代码正在准备好的文档上运行,此时所有问题都将无法得到解答。

您需要将事件处理程序绑定(bind)到单选按钮

$(function(){
$('#vote_submit_button').hide();
var answered = new Array();
$('input:radio').change(function(){
var $this= $(this);
if ($this.is(':checked')){
anwered.push($this.attr('name'));
}

if (answered.length == $('table').length) {
$('#vote_submit_button').show();
}

});
});

关于javascript - 单选按钮组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26301377/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com