js 多选题选项内容显示在标题下
<body>
<div class="page-container">
<div class="view-container">
<header class="navbar">
<div class="navbar-back" onclick="window.history.go(-1)">返回</div>
<h2 class="navbar-con">页面标题</h2>
</header>
<div class="container">
<section class="check-sub-back">
<div class="check-sub-title" >
<p class="bank-card-linked" id="title">1.这是一个多选题,你的选择是?<br/>
</p>
<p class="option-txt" id="option-txt"> </p>
<p class="opt-arrow-right"></p> </div>
<div class="check-sub-box" id="box">
<ul class="adr-row" style="border-bottom:1px solid #e6e6e6; ">
<li>
<a href="controller.html" class="row-cancel">
取消
</a>
</li>
<li>
<a class="row-place">多选标题</a>
</li>
<li>
<a href="bankcard.html" class="row-save">
保存
</a>
</li>
</ul>
<div class="option-box">
<ul id="option-box">
<li class="item" id="option1">
<input type="checkbox" value="选项 1" class="hide checkbox-checked" id="checkbox-f1"/>
<label for="checkbox-f1" class="checkbox-default">
选项 1
</label>
</li>
<li class="item" id="option2">
<input type="checkbox" value="选项 2" class="hide checkbox-checked" id="checkbox-f2"/>
<label for="checkbox-f2" class="checkbox-default">
选项 2
</label>
</li>
<li class="item" id="option3">
<input type="checkbox" value="选项 3" class="hide checkbox-checked" id="checkbox-f3"/>
<label for="checkbox-f3" class="checkbox-default">
选项 3
</label>
</li>
<li class="item" id="option4">
<input type="checkbox" value="选项 4" class="hide checkbox-checked" id="checkbox-f4"/>
<label for="checkbox-f4" class="checkbox-default">
选项 4
</label>
</li>
<li class="item" id="option5">
<input type="checkbox" value="选项 5" class="hide checkbox-checked" id="checkbox-f5"/>
<label for="checkbox-f5" class="checkbox-default">
选项 5
</label>
</li>
<li class="item" id="option6">
<input type="checkbox" value="选项 6" class="hide checkbox-checked" id="checkbox-f6"/>
<label for="checkbox-f6" class="checkbox-default">
选项 6
</label>
</li>
</ul>
</div>
</div>
</section>
</div> </div>
</div>
</body>
<script type="text/javascript">
window.onload = function() {
var title = document.getElementById('title'); //获取id为title的元素
var box = document.getElementById('box');
title.onclick = function () { //title 元素点击时
box.style.display = 'block';//box中css样式修改 display:block;
}
var list = document.querySelectorAll("#option-box li"); //获取所有的#option-box li 放到list中
var optxt = document.getElementById('option-txt');
console.log(list);
var test = {};//创建对象
for (var i = 0; i < list.length; i++) {
list[i].onchange = function (e) {//onchange事件点击一次是true,再次点击是false
optxt.innerHTML = "";
test[e.target.value] = e.target.checked; 获取值
console.log(test);
console.log(test[e.target.value]);
for(var item in test) {//遍历
if (!!test[item]) {
optxt.innerHTML += item + ' ';//赋值
// console.log(e.target.value);
}
console.log(item);
} } } }
</script>
</html>
/*多选按钮样式 <-- start --> */
.checkbox-default {
position: relative;
width: 90%;
padding: 0 18px 0 38px;
height: 60px;
display: block;
line-height: 60px;
color: #333;
}
.checkbox-default::before {
content: "";
position: absolute;
left: 0;
top: 18px;
width: 21px;
height: 21px;
margin-right: 18px;
color: #666;
background-color: #fff;
border: 1px solid #999;
border-radius: 5px;
} .checkbox-checked:checked + .checkbox-default::before {
content: "";
color: #3399ff;
border: 1px solid #3399ff;
background: url("../../images/radio-checkd-icon.png") #3399ff center no-repeat;
margin-right: 12px;
background-size: 12px 10px;
}
/* <-- end --> */
/*复选页面 题目中显示选项内容 <-- start --> */
.check-sub-back{
background-color: rgba(0, 0, 0, 0.2);
font-size: 14px;
height: 1850px;
z-index:10;
position: fixed;
width:100%;
}
.check-sub-title{
background-color: #e6e6e6;
font-size:18px;
position: relative;
} .check-sub-title:active {
background-color: #efefef; }
.check-sub-box{
width: 100%;
min-width: 320px;
background: #fff;
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 999;
display: none;
animation: fadeInUp .3s .2s ease both;
} .opt-arrow-right {
background-image: url("../../images/arrow_right.png");
background-size: 10px 14px;
background-repeat: no-repeat;
width: 20px;
height: 20px;
position: absolute ;
top:57%;
right:1%;
transform: translate( -50%, -50%);
-webkit-transform: translate( -50%, -50%);
-moz-transform: translate( -50%, -50%);
-o-transform: translate( -50%, -50%); } .option-box{ background: #fff;
height:280px;
overflow-y: scroll;
}
.option-box .item {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
position: relative;
font-size: 18px;
padding-left: 18px;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
} .option-box .item::before {
content: "";
position: absolute;
left: 0;
width: 200%;
height: 0;
border-bottom: 1px solid #d7d7d7;
transform-origin: left top;
transform: scale3d(0.5, 0.5, 0.5);
top: 0;
} .option-box li:active {
background-color: #efefef;
} .option-txt{
font-size: 16px;
color: #999999;
padding: 0 0 10px 22px;
margin-top: -10px;
}
/* <-- end --> */
js 多选题选项内容显示在标题下的更多相关文章
- Firebug中调试中的js脚本中中文内容显示为乱码
Firebug中调试中的js脚本中中文内容显示为乱码 设置 页面 UFT-8 编码没用, 解决方法:点击 "Firebug"工具栏 中的"选项"---" ...
- js如何实现点击显示和隐藏表格
js如何实现点击显示和隐藏表格 一.总结 一句话总结: 1.给table或者table里面的元素添加点击事件, 2.然后判断当前表格的数据显示或者隐藏, 3.然后通过display属性显示(非none ...
- DOM操作 、js获取id的内容 和修改原来的内容(innerHTML)
js获取id的内容(getElementById) 和修改原来的内容(innerHTML) 1.通过ID获取元素 学过HTML/CSS样式,都知道,网页由标签将信息组织起来,而标签的id属性值是唯一的 ...
- 用css3让溢出内容显示省略号
css3现在越来越普及了.给我们前端人员也带来了极大的便利.以前要实现让溢出的内容显示省略号还得通过js实现,现在完全可以用css代替之. 主要的代码如下: <style type=" ...
- js读取本地图片并显示
抄自 http://blog.csdn.net/qiulei_21/article/details/52785191 js读取本地图片并显示 第一种方法比较好 版权声明:本文为博主原创文章,未经博主允 ...
- JS正则表达式获取分组内容实例
JS正则表达式获取分组内容. 支持多次匹配的方式: var testStr = "now test001 test002"; var re = /test(\d+)/ig; var ...
- 超棒的JS移动设备滑动内容幻灯实现 - Swiper
来源:GBin1.com 在线演示 如果你需要一款帮助你实现手机或者移动设备上内容幻灯实现的JS类库的话 , Swiper是一个不错的选择,它不依赖于任何第三方的类库.因此体积非常小,适合运行在移动设 ...
- 织梦DedeCMS判断简略标题为空时则显示完整标题
使用织梦DedeCMS系统程序开发网站中,我们会遇到很多因网页版面设计限定的宽度,使文章标题需要进行字数限制,通常做法是在a标签中加入一个title属性,让鼠标放上去的时候显示完整标题.但是标题被剪裁 ...
- arcgis api 3.x for js 解决 textSymbol 文本换行显示(附源码下载)
前言 关于本篇功能实现用到的 api 涉及类看不懂的,请参照 esri 官网的 arcgis api 3.x for js:esri 官网 api,里面详细的介绍 arcgis api 3.x 各个类 ...
随机推荐
- 图解SQL多表关联查询
图解SQL多表关联查询 网上看了篇文章关于多表连接的,感觉很好,记录下来,以便日后自己学习 内连接 左连接 右连接 全外连接 1. 查两表关联列相等的数据 ...
- Java List 如何传值
// 合并 List 中的相同数据行 // Source : tmpOrderEntryListBeanList // Target : resultOrderEntryListBeanList // ...
- linux ntp时间同步
linux ntp时间同步 一.搭建时间同步服务器1.编译安装ntp serverrpm -qa | grep ntp若没有找到,则说明没有安装ntp包,从光盘上找到ntp包,使用rpm -Uvh n ...
- 【转】JavaScript中的this关键字使用的四种调用模式
http://blog.csdn.net/itpinpai/article/details/51004266 this关键字本意:这个.这里的意思.在JavaScript中是指每一个方法或函数都会有一 ...
- css中IE6fix问题
.g-popup-mask, .g-popup-box { position:fixed; top:0; left:0; z-index:10000; _position:absolute; _top ...
- 业界有很多MQ产品
目前业界有很多MQ产品,我们作如下对比: RabbitMQ 是使用Erlang编写的一个开源的消息队列,本身支持很多的协议:AMQP,XMPP, SMTP, STOMP,也正是如此,使的它变的非常重量 ...
- C#调用NPOI组件导出Excel表格
把一个List集合的数据导出到Excel表格中 public static string RenderToExcel<T>(List<T> datas) { MemoryStr ...
- LinQ总结
不管是在Mvc还是在别的架构中的项目LinQ和Lambda总是经常会遇到的. 而有些LinQ的语法并不是很长用(我大部分用的是Lambda),所以有必要记录一下万一用到的时候我能很方便的找到我想找到的 ...
- js判断图片是否存在,并做处理
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...
- 用httpPost对JSON发送和接收
HTTPPost发送JSON: private static final String APPLICATION_JSON = "application/json"; private ...