Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.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
C# jQuery选择所有未回答的多项选择题_C#_Jquery_Asp.net - Fatal编程技术网

C# jQuery选择所有未回答的多项选择题

C# jQuery选择所有未回答的多项选择题,c#,jquery,asp.net,C#,Jquery,Asp.net,你能帮我吗 我需要一个jquery代码来选择多项选择题测试中所有未回答的问题。 多项选择题有三种类型: 1个单一答案 2多答案 3是/否回答 通过选择,我的意思是使问题/答案的背景变成另一种颜色,单击复选框显示未回答的问题 <div class="container-fluid"> <div> <input id="unansweredquestion" type="checkbox" name="uquestion"

你能帮我吗

我需要一个jquery代码来选择多项选择题测试中所有未回答的问题。 多项选择题有三种类型: 1个单一答案 2多答案 3是/否回答

通过选择,我的意思是使问题/答案的背景变成另一种颜色,单击复选框显示未回答的问题

    <div class="container-fluid">
        <div>
            <input id="unansweredquestion" type="checkbox" name="uquestion" /><label for="unansweredquestion"> Show Unanswered Questions</label>
        <div>
        <div class="card">
            <div class="card-header">
                <strong>
                    Question
                    <span id="maincontent_lvTest_lblRowNumber_0">1</span>
                </strong>
                <div style="float: right">
                    <input id="maincontent_lvTest_CheckBox1_0" type="checkbox" name="ctl00$maincontent$lvTest$ctrl0$CheckBox1" /><label for="maincontent_lvTest_CheckBox1_0"> Doubtful</label>
                </div>
            </div>
            <div class="card-body">
                <h5 class="card-title">
                    <input type="hidden" name="ctl00$maincontent$lvTest$ctrl0$hfQuesId" id="maincontent_lvTest_hfQuesId_0" value="3088" />
                    <input type="hidden" name="ctl00$maincontent$lvTest$ctrl0$hfQuestionType" id="maincontent_lvTest_hfQuestionType_0" value="2" />
                    <span id="maincontent_lvTest_lblQuestiontext_0">Who created the World?</span>
                </h5>
                <p class="card-text">
                    <table id="maincontent_lvTest_CheckBoxList1_0">
                        <tr>
                            <td><input id="maincontent_lvTest_CheckBoxList1_0_0_0" type="checkbox" name="ctl00$maincontent$lvTest$ctrl0$CheckBoxList1$0" value="2169" /><label for="maincontent_lvTest_CheckBoxList1_0_0_0">Extraterrestrial Being</label></td>
                        </tr>
                        <tr>
                            <td><input id="maincontent_lvTest_CheckBoxList1_0_1_0" type="checkbox" name="ctl00$maincontent$lvTest$ctrl0$CheckBoxList1$1" value="2167" /><label for="maincontent_lvTest_CheckBoxList1_0_1_0">God</label></td>
                        </tr>
                        <tr>
                            <td><input id="maincontent_lvTest_CheckBoxList1_0_2_0" type="checkbox" name="ctl00$maincontent$lvTest$ctrl0$CheckBoxList1$2" value="2168" /><label for="maincontent_lvTest_CheckBoxList1_0_2_0">Man</label></td>
                        </tr>
                    </table>
                </p>
            </div>
        </div>


        <div class="card">
            <div class="card-header">
                <strong>
                    Question
                    <span id="maincontent_lvTest_lblRowNumber_1">2</span>
                </strong>
                <div style="float: right">
                    <input id="maincontent_lvTest_CheckBox1_1" type="checkbox" name="ctl00$maincontent$lvTest$ctrl1$CheckBox1" /><label for="maincontent_lvTest_CheckBox1_1"> Doubtful</label>
                </div>
            </div>
            <div class="card-body">
                <h5 class="card-title">
                    <input type="hidden" name="ctl00$maincontent$lvTest$ctrl1$hfQuesId" id="maincontent_lvTest_hfQuesId_1" value="3116" />
                    <input type="hidden" name="ctl00$maincontent$lvTest$ctrl1$hfQuestionType" id="maincontent_lvTest_hfQuestionType_1" value="3" />
                    <span id="maincontent_lvTest_lblQuestiontext_1">Is the Earth round?</span>
                </h5>
                <p class="card-text">
                    <table id="maincontent_lvTest_RadioButtonList2_1">
                        <tr>
                            <td><input id="maincontent_lvTest_RadioButtonList2_1_0_1" type="radio" name="ctl00$maincontent$lvTest$ctrl1$RadioButtonList2" value="2336" /><label for="maincontent_lvTest_RadioButtonList2_1_0_1">No</label></td>
                        </tr>
                        <tr>
                            <td><input id="maincontent_lvTest_RadioButtonList2_1_1_1" type="radio" name="ctl00$maincontent$lvTest$ctrl1$RadioButtonList2" value="2335" /><label for="maincontent_lvTest_RadioButtonList2_1_1_1">Yes</label></td>
                        </tr>
                    </table>
                </p>
            </div>
        </div>

        <div class="card">
            <div class="card-header">
                <strong>
                    Question
                    <span id="maincontent_lvTest_lblRowNumber_2">3</span>
                </strong>
                <div style="float: right">
                    <input id="maincontent_lvTest_CheckBox1_2" type="checkbox" name="ctl00$maincontent$lvTest$ctrl2$CheckBox1" /><label for="maincontent_lvTest_CheckBox1_2"> Doubtful</label>
                </div>
            </div>
            <div class="card-body">
                <h5 class="card-title">

                    <input type="hidden" name="ctl00$maincontent$lvTest$ctrl2$hfQuesId" id="maincontent_lvTest_hfQuesId_2" value="3082" />
                    <input type="hidden" name="ctl00$maincontent$lvTest$ctrl2$hfQuestionType" id="maincontent_lvTest_hfQuestionType_2" value="1" />
                    <span id="maincontent_lvTest_lblQuestiontext_2">Who wrote "The man is the man"?</span>
                </h5>
                <p class="card-text">

                    <table id="maincontent_lvTest_RadioButtonList1_2">
                        <tr>
                            <td><input id="maincontent_lvTest_RadioButtonList1_2_0_2" type="radio" name="ctl00$maincontent$lvTest$ctrl2$RadioButtonList1" value="2134" /><label for="maincontent_lvTest_RadioButtonList1_2_0_2">Ryan</label></td>
                        </tr>
                        <tr>
                            <td><input id="maincontent_lvTest_RadioButtonList1_2_1_2" type="radio" name="ctl00$maincontent$lvTest$ctrl2$RadioButtonList1" value="2132" /><label for="maincontent_lvTest_RadioButtonList1_2_1_2">Daudet</label></td>
                        </tr>
                        <tr>
                            <td><input id="maincontent_lvTest_RadioButtonList1_2_2_2" type="radio" name="ctl00$maincontent$lvTest$ctrl2$RadioButtonList1" value="2133" /><label for="maincontent_lvTest_RadioButtonList1_2_2_2">Claude</label></td>
                        </tr>
                        <tr>
                            <td><input id="maincontent_lvTest_RadioButtonList1_2_3_2" type="radio" name="ctl00$maincontent$lvTest$ctrl2$RadioButtonList1" value="2131" /><label for="maincontent_lvTest_RadioButtonList1_2_3_2">Alphone</label></td>
                        </tr>
                    </table>
                </p>
            </div>
        </div>
</div>
非常感谢


Tairon

我将您的html切碎,并为表中的.answers添加了一个类。我还将输入移动到标签中。现在,这个小例子将向您展示如何做到这一点

在上次注释后编辑代码

我已经修改了评论中描述的案例的jQuery部分。现在,如果需要,可以在一个页面上创建多个问题/答案

$document.readyfunction{ $“未回答的问题”。在“更改”上,切换未回答的问题; $'.回答输入[type=checkbox]'。在“更改”上,切换未回答的问题; 功能切换未回答的问题{ var-toggleCheckbox=$‘未回答的问题’; var answers=$'.answers'; 如果切换CheckBox.prop'checked'{ 答案。每个函数索引,答案{ var$answer=$answer; var hasAnswers=$answer.find'input:checked'。长度>0; 如果有答案{ $answer.removeClass“突出显示”; }否则{ $answer.addClass“突出显示”; } }; }否则{ 答案。移除“突出显示”类; } } }; .突出显示{背景色:f00;颜色:0f0;} 显示未回答的问题 外星生物 上帝 成年男子 将类名作为问题添加到问题卡中 将类名添加为,答案为答案。 “添加类以更改未回答问题的背景”复选框被触发 代码:

.未答复{ 背景:蔚蓝; } 显示 没有答案的问题 问题 1. 可疑的 谁创造了世界?

外星的 存在 上帝 成年男子

问题 2. 可疑的 地球是圆的吗?

不 对

问题 3. 可疑的 谁写的这个人就是那个人?

赖安 道代特 克劳德 唱机

$document.readyfunction{ 获得有争议的问题; 未回答的切换; }; 函数GetAllunsWeredQuestions{ $“未回答的问题”。关于“更改”,函数{ 如果$this.is:已选中{ 常量问题=$'。问题'; 问题.每个函数{ 如果!$this.find'.answer'.is':已选中{ $this.addClass“未答复”; } }; }否则{ $'.question'.removeClass'unanswered' } }; } 函数切换未应答{ $'.answer'。关于“更改”,函数{ const isChecked=$this.is:checked; 如果$'unansweredquestion'.is:已选中{ 如果我检查过{ $this.offsetParent.removeClass'unanswered'; }否则{ $this.offsetParent.addClass'unanswered'; } } }; }
您好UfguFugullu,这是为您修改的表工作,但请注意,Asp.net正在根据我发布的内容生成我的代码。你能把你的密码修改一下以符合我贴的密码吗。Thxx。tairon@Tairon你只需要在课堂上做一个改变。我非常确信,即使使用ASP.Net,您也可以将课堂答案添加到表中。如果没有,请将选择器“.answer”更改为适合您的标记的东西,如“table”Hi UfguFugullu,我正在尝试修改您给我的代码,它工作正常,除了一件事。当我选择复选框的任何项目时,此问题的所有复选框都不需要突出显示。如果未选中任何复选框,则需要再次突出显示该复选框。谢谢tairon@Tairon我已经修改了你描述的案例的代码谢谢UfguFugullu,效果很好。我是jQuery新手,请您指导我在哪里可以学习jQuery。任何网站、教程、视频。谢谢againHi Lasanga Guruge,看起来不错。但当我取消选中某个问题的所有复选框时,该问题需要再次高亮显示为未回答。你能修改一下代码吗。谢谢。tairon@Tairon增加了切换功能