javascript - 我将如何进行如果大学是检查然后这门课程将在下拉列表中?
问题描述
So I am trying to do an that If the College is selected in the checkbox then the college course would show like
BS-IT, BS-IT-DA, BS-CS 在下拉列表中,否则如果高级选中,则链将显示 GAS、IT、CS。我不知道 JavaScript 或 J-Query 是否需要它
<div class="form-group right">
<label class="label-title">Status</label>
<div>
<label><input type="checkbox">College Student</label>
<label><input type="checkbox" class="senior-high" >Senior High</label>
</div>
</div>
<div class="horizontal-group">
<div class="form-group left">
<label for="">Course</label>
<select id="Course"></select>
</div>
</div>
解决方案
//首先在拼贴复选框上添加 id="collage" 并在所有复选框上添加 class="checkbox" 在高级 hs 复选框上添加 Senior_highcheckbox id
$(document).on('click','.checkbox'function(){
if($('#college').is('checked')){
$('#course').append(`<option>BS-IT </option>
<option>BS-IT-DA</option>
<option>BS-CS</option>`);
$('#senior_highcheckbox').attr('checked',false);
}else{
$('#course').append(`<option>GAS</option>
<option>IT</option>
<option>CS</option>`);
$('#college').attr('checked',false);
}
})
推荐阅读
- azure - 如何从 Azure 上运行的 Web 应用连接到远程 API
- tomcat - 如何在 Tomcat 控制台日志中记录 sessionId?
- android - 从带有附加功能的命令行终端启动快捷方式?
- html - 将基本身份验证与 Web 应用程序和 CDN 结合使用的最简化方式
- javascript - 如何将焦点设置在 onRowClicked 行中的第一个可编辑单元格上?
- java - 使用 Java 中的构造函数初始化二维数组
- mysql - 迭代列以显示时间之间的计数
- sql - 需要帮助定位 SQL 列中的特定字符
- excel - 创建 Excel 公式以从另一行返回特定的非空白映射值
- javascript - 带有身份验证的 aws-amplify 是否损坏?