javascript - Javascript - 模式选择选项(无法选择模式中的项目)
问题描述
有人可以告诉我如何扩展我的代码吗?
我想做的是:
- 单击时
plots_container
,会提示一个包含图表列表的模式 - 当用户点击图表时(例如:
line plot
在模式中),span 中声明hello
hello 的内容变为<span>line plot</span>
- 我想做这样的事情
目前,我刚刚设法在plots_container
单击时提示模式。
如果有人可以查看我在以下文件中尝试过的内容并提供建议或反馈,我将不胜感激。
索引.html
<span class="modal_content">
<select class="hide seriesDetails" title="Type of Chart for this Series" id="ChartType" name="ChartType"><option selected="selected" value="17">Pie</option></select>
<div class="seriesDetails" id="plots_container">
<span>hello</span>
</div>
<div id="plotList">
<ul>
<li class="business">
<div class="image_text_content">
<div class="image_container"><img src="Content/images/plot-thumbs/1-scatter-plot.jpg" alt="scatter-plot"></div>
<div class="plot_title">scatter plot</div>
</div>
<div class="image_text_content">
<div class="image_container"><img src="Content/images/plot-thumbs/2-line-plot.jpg" alt="scatter-plot"></div>
<div class="plot_title">line plot</div>
</div>
</li>
</ul>
</div>
</span>
应用程序.js
// modal to display types of plots
$(document).ready(function() {
$('#plots_container').click(function() {
$('#plotList').fadeToggle();
})
$(document).mouseup(function (e) {
var container = $("#plotList");
if (!container.is(e.target) // if the target of the click isn't the container...
&& container.has(e.target).length === 0) // ... nor a descendant of the container
{
container.fadeOut();
}
});
});
解决方案
快速 JSFiddle:https ://jsfiddle.net/hxnm7q2L/1/展示如何使用
.addEventListener("change", function(e) {
触发显示模态中选定值的值变化。
推荐阅读
- python - 从 numpy.random.multinomial 获取随机的索引数组
- python - 如何选择具有特定值的列迭代数据框中的所有行?
- python - 如何构建thundersvm?
- sql - 插入表中包含 BigQuery 中的重复记录
- django - Django 本地化路径分隔符 Windows (\) vs macOS (/)
- javascript - laravel-mix-polyfill 需要 babel 未处理的语句
- vba - 如何在 MS Access 中反映/复制从一种形式到另一种形式的更改
- angular - 如何在 Angular8 中使用 js-year-calendar
- python - 无法将字节转换为 JSON
- php - PHP - 为 Salesforce API 生成正确的 SOAP 数据