- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试设置一个页面,人们可以通过在网络表单中选择“开始”来触发调查问卷 - 它会弹出第一个问题的 DIV。
当他们回答每个问题(是/否选择)时,它要么打开一个特定于该问题的 DIV,其中显示“不 - 离开,因为 XXXX”,要么在新的 DIV 中提出下一个问题...这会重复大约 8次。
到目前为止,我可以显示第一个问题,但当我选择问题 1 的答案时它不会执行任何操作 - 它应该使 Q2 DIV 出现或提供上下文 DIV 来说明为什么他们无法继续。
我在this jsfiddle link中有一个(非常)精简的演示
HTML 代码是:
<div class="container">
<form id="GeneralEnquiryForm" class="row justify-content-center no-gutters col-12" name="GeneralEnquiry" method="post" action="https://somesite.com/forms/accessrequest/request_submitted.php" enctype="multipart/form-data" data-toggle="validator">
<div class="form-group row justify-content-center col-sm-12 col-md-12 col-lg-10 col-xl-10">
<div id="GeneralEnquiryHeading">
<h2>Request Form</h2>
</div>
</div>
<!-- ############################ -->
<!-- # Main Menu Selection Tree # -->
<!-- ############################ -->
<div class="form-group row justify-content-center col-sm-12 col-md-12 col-lg-10 col-xl-10">
<div class="form-group col-12">
<label for="requestSelect">This checklist MUST be complete to submit this form. *</label>
<select class="form-control" name="requestSelect" id="requestSelect" required>
<option value="" selected disabled="disabled">Please select the check to begin.</option>
<option title="Option 1" value="HealthCheck">Commence Checklist</option>
</select>
</div>
<!-- ############################# -->
<!-- # Health Check # -->
<!-- ############################# -->
<div class="form-group col-12 clearAll HealthCheck fade show" role="dialog">
<div>
<h6>Request Form</h6>
<h2>CHECK LIST</h2>
</div>
<label for="HealthCheck1">Have you returned from overseas travel in the past 14 days? *</label>
<select class="form-control" name="HealthCheck1" id="HealthCheck1" required>
<option value="" selected disabled="disabled"> Please select Yes or No </option>
<option title="HealthCheck1Yes" value="HealthCheck1Yes">Yes</option>
<option title="HealthCheck1No" value="HealthCheck1No">No</option>
</select>
</div>
</div>
<div class="form-group col-12 clearAll HealthCheck1No alert alert-info fade show" role="alert">
<label for="HealthCheck2">Have you returned from interstate travel in the past 14 days? *</label>
<select class="form-control" name="HealthCheck2" id="HealthCheck2" required>
<option value="" selected disabled="disabled"> Please select Yes or No </option>
<option title="HealthCheck2Yes" value="HealthCheck2Yes">Yes</option>
<option title="HealthCheck2No" value="HealthCheck2No">No</option>
</select>
</div>
<div class="form-group col-12 clearAll HealthCheck2No alert alert-info fade show" role="alert">
<label for="HealthCheck3">Are you currently required to self-isolate? *</label>
<select class="form-control" name="HealthCheck3" id="HealthCheck3" required>
<option value="" selected disabled="disabled"> Please select Yes or No </option>
<option title="HealthCheck3Yes" value="HealthCheck3Yes">Yes</option>
<option title="HealthCheck3No" value="HealthCheck3No">No</option>
</select>
</div>
<!-- ############################ -->
<!-- # Health Check Pop-Up Help # -->
<!-- ############################ -->
<div class="form-group col-12 clearAll HealthCheck1Yes alert alert-warning fade show" role="alert">
<h5>Do <strong>NoT</strong> attend campus!</h5>
<div class="row col-12 align-items-center">
<div class="termsIcon col-2 .col-sm-2 col-md-2 col-lg-1 col-xl-1">
<img src="../images/warning_small.png" class="rounded float-left" alt="">
</div>
<div class="col">
<h6><strong>If you have returned from overseas travel in the past 14 days, you should be self-isolating.</strong></h6></br>
</div>
</div>
</div>
<div class="form-group col-12 clearAll HealthCheck2Yes alert alert-warning fade show" role="alert">
<h5>Do <strong>NoT</strong> attend campus!</h5>
<div class="row col-12 align-items-center">
<div class="termsIcon col-2 .col-sm-2 col-md-2 col-lg-1 col-xl-1">
<img src="../images/warning_small.png" class="rounded float-left" alt="">
</div>
<div class="col">
<h6><strong>If you have returned from interstate travel in the past 14 days, you should be self-isolating</strong></h6></br>
</div>
</div>
</br></br>
</div>
<!-- ############################# -->
<!-- # Individual Pop-Up Modules # -->
<!-- ############################# -->
<hr class="separator col-12">
* Please fill in ALL of the above fields or the form will not submit.
<hr class="separator col-12">
<div id="new-div"></div>
<div class="form-group justify-content-right col-sm-12 col-md-12 col-lg-10 col-xl-10">
<button type="submit" value="Submit" id="submit" class="btn btn-primary float-right" onclick="return checkform()">Submit Request</button>
</div>
</form>
</div>
</div>
Javascript
<script src="https://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/1000hz-bootstrap-validator/0.11.9/validator.js"></script>
<script>
$(function () {
$("#requestSelect").change(function() {
var val = $(this).val();
if(val === "HealthCheck") {
$(".clearAll").hide();
$(".HealthCheck").show();
}
});
});
</script>
<script>
$(function () {
$("#HealthCheck1").change(function() {
var val = $(this).val();
if(val === "HealthCheck1Yes") {
$(".HealthCheck1Yes").show();
}
else if(val === "HealthCheck1No") {
$(".HealthCheck1No").show();
}
}
});
</script>
[编辑 - 修复 JSFiddle]
最佳答案
您错过了最后关闭函数 })
:
$("#HealthCheck1").change(function() {
var val = $(this).val();
if(val === "HealthCheck1Yes") {
$(".HealthCheck1Yes").show();
}
else if(val === "HealthCheck1No") {
$(".HealthCheck1No").show();
}
});
还有一些其他建议可供您考虑:
使用自闭合 HTML 标记的正确语法。使用<br />
而不是</br>
.
使用正确的缩进(适用于所有文档)可以帮助您更快地找到未关闭的函数和其他错误。
将您的 javascript 放入适当的文件中,然后将其包含在 <script src="myscripts.js"></script>
中。这将允许您的代码编辑器(如 intellij)检测简单的结束标记/函数问题。
关于javascript - 使用 javascript 在 HTML 选择的嵌入 DIV 中显示 DIV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60898650/
我正在开发一个小型 Web 应用程序,其中有一个 object 元素(包含一个 embed),用于显示小型文档。 文档可以是 PDF 或纯文本文件 (.txt),我以 base64 字符串的形式从 W
我有一种小型语言,它基本上是 OCaml 的扩展(实际上它是 OCaml 子集的扩展,但这并不重要)。为了简化事情,我有一个“转义”表达式,可以将 OCaml 文字传输到我的语言中(因此您可以将任意
据我所知,我知道 embed tag用于嵌入来自 youtube 等网站的视频,object tag用于 Flash 视频和 video tags下HTML5 .但我很好奇这些标签的深入细节以及作为开
我假设您可以将 WebKit 嵌入到另一个桌面应用程序中并向其发送一个字符串,例如: Hello world! 它将显示在窗口内。 我的问题是,如果我将其压缩表示(JPEG 转储)加载到内存中,我该如
有没有一种可能的方式,我可以从youtube检索我的最新视频的列表(带有缩略图),使用cron作业将嵌入的代码存储在数据库中,这样我就可以在单独的页面上显示视频,而不是将用户引向youtube观看视频
最近我发现我的网站上嵌入的 YouTube 视频存在问题 - 全屏按钮不再起作用。确实有过一次。该按钮是可见的,但单击时没有任何反应。 我正在使用 Youtube Javascript API 将视频
在 Keras 内置函数中嵌入使用哪种算法?Word2vec?手套?其他? https://keras.io/layers/embeddings/ 最佳答案 简短的回答是都不是。本质上,GloVe 的
在 LSTM 上用于建模 IMDB 序列数据 ( https://github.com/fchollet/keras/blob/master/examples/imdb_lstm.py ) 的 ker
在机器学习中,通常用 one-hot-encoding 表示分类(特别是:名义)特征。 .我正在尝试学习如何使用 tensorflow 的嵌入层来表示分类问题中的分类特征。我有 tensorflow
我有一个使用 Storyboard的应用程序,我想在我的主视图中有一个 View ,并让它在场景中的不同 View 之间切换。 所以目前我有“容器对象”,我可以在其中嵌入另一个 viewControl
在我的项目中我遇到了这样的情况。 function fonsubmit() { alert('Out side PHP'); //Here the php code starts
我正在尝试添加一个JFileChooser,它选择父目录并允许用户输入文件名称。我知道 showSaveDialog 和 showOpenDialog 方法,但我不想创建新窗口。 这是我到目前为止所拥
我注意到我的网站创建了这样的链接:www.domain.com/post-name/embed/ 恐怕这可能会影响 SEO。是否可以禁用此功能? 最佳答案 显然这是默认的 WordPress 行为。此
我试图从 C 代码调用 python 函数,我遵循了 here 中的示例 我也有正确的包含文件目录、库目录和链接 python32.lib(我使用 python 32)但是错误是 python/C A
我正在使用基于云的 EDR 平台来监控客户端受损网络上发生的进程。我最近经常看到的是使用选项“-Embedding”调用的 msiexec.exe C:\Windows\System32\MsiExe
我有一个列表,其中包含数百万个需要嵌入的句子。我正在使用 Flair以此目的。这个问题似乎应该是并行的。但是,当我尝试优化时,我的性能要么没有提高,要么只是停滞不前。 我将我的句子定义为一个简单的字符
我想在我的应用程序中添加嵌入的 YouTube 视频:我该怎么做?我有这个 import 'package:youtube_player/youtube_player.dart'; import 'p
我有 json 看起来像: myjson = {"queries":{"F.SP": 27}} 所以与 queryResults = JObject.Parse(jsonString) 我可以 fir
我在 html 文档中嵌入 highcharts 饼图时遇到问题。具体来说,我无法在不更改图表大小的情况下调整图表容器的大小。有谁知道您是否可以在不缩小图表的情况下减少默认填充?或者,您可以在不增加容
我不太确定这在 MediaWiki 中是否可行。 我有几个类别,每个类别包含几页。如果您打开一个类别页面,您将看到该类别的内容,通常由以下三个部分组成: 用户定义的文本(可以使用编辑链接进行编辑)。
我是一名优秀的程序员,十分优秀!