<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 多选题选项内容显示在标题下的更多相关文章

  1. Firebug中调试中的js脚本中中文内容显示为乱码

    Firebug中调试中的js脚本中中文内容显示为乱码 设置 页面 UFT-8 编码没用, 解决方法:点击 "Firebug"工具栏 中的"选项"---" ...

  2. js如何实现点击显示和隐藏表格

    js如何实现点击显示和隐藏表格 一.总结 一句话总结: 1.给table或者table里面的元素添加点击事件, 2.然后判断当前表格的数据显示或者隐藏, 3.然后通过display属性显示(非none ...

  3. DOM操作 、js获取id的内容 和修改原来的内容(innerHTML)

    js获取id的内容(getElementById) 和修改原来的内容(innerHTML) 1.通过ID获取元素 学过HTML/CSS样式,都知道,网页由标签将信息组织起来,而标签的id属性值是唯一的 ...

  4. 用css3让溢出内容显示省略号

    css3现在越来越普及了.给我们前端人员也带来了极大的便利.以前要实现让溢出的内容显示省略号还得通过js实现,现在完全可以用css代替之. 主要的代码如下: <style type=" ...

  5. js读取本地图片并显示

    抄自 http://blog.csdn.net/qiulei_21/article/details/52785191 js读取本地图片并显示 第一种方法比较好 版权声明:本文为博主原创文章,未经博主允 ...

  6. JS正则表达式获取分组内容实例

    JS正则表达式获取分组内容. 支持多次匹配的方式: var testStr = "now test001 test002"; var re = /test(\d+)/ig; var ...

  7. 超棒的JS移动设备滑动内容幻灯实现 - Swiper

    来源:GBin1.com 在线演示 如果你需要一款帮助你实现手机或者移动设备上内容幻灯实现的JS类库的话 , Swiper是一个不错的选择,它不依赖于任何第三方的类库.因此体积非常小,适合运行在移动设 ...

  8. 织梦DedeCMS判断简略标题为空时则显示完整标题

    使用织梦DedeCMS系统程序开发网站中,我们会遇到很多因网页版面设计限定的宽度,使文章标题需要进行字数限制,通常做法是在a标签中加入一个title属性,让鼠标放上去的时候显示完整标题.但是标题被剪裁 ...

  9. arcgis api 3.x for js 解决 textSymbol 文本换行显示(附源码下载)

    前言 关于本篇功能实现用到的 api 涉及类看不懂的,请参照 esri 官网的 arcgis api 3.x for js:esri 官网 api,里面详细的介绍 arcgis api 3.x 各个类 ...

随机推荐

  1. Yii源码阅读笔记(六)

    组件(component),是Yii框架的基类,实现了属性.事件.行为三类功能,如果需要事件和行为的功能,需要继承该类,不需要可直接继承Object类: namespace yii\base; use ...

  2. java 客户端获取真实ip地址

    在开发工作中,我们常常需要获取客户端的IP.一般获取客户端的IP地址的方法是:request.getRemoteAddr();但是在通过了Apache,Squid等反向代理软件就不能获取到客户端的真实 ...

  3. linux ntp时间同步

    linux ntp时间同步 一.搭建时间同步服务器1.编译安装ntp serverrpm -qa | grep ntp若没有找到,则说明没有安装ntp包,从光盘上找到ntp包,使用rpm -Uvh n ...

  4. iOS 键盘隐藏

     IOS7 点击空白处隐藏键盘的几种方法   IOS开发中经常要用到输入框,默认情况下点击输入框就会弹出键盘,但是必须要实现输入框return的委托方法才能取消键盘的显示,对于用户体验来说很不友好,我 ...

  5. 常见的Mule Esb下载地址

    http://www.myexception.cn/open-source/1832157.html

  6. c# ToString() 用法

    string tempa = Convert.ToString(31, 2);//将10进制数31转换为2进制字符串. string strNums = int.Parse(tempa).ToStri ...

  7. Cocos2d-JS目录说明

    frameworks---- 引擎所在,包含两个文件夹cocos2d-html5 和js-bindings.前者是html5引擎,后者是-x的引擎,外部接口是js写,但基础模块却是cpp来实现. sa ...

  8. 1001 数组中和等于K的数对

    1001 数组中和等于K的数对 基准时间限制:1 秒 空间限制:131072 KB 给出一个整数K和一个无序数组A,A的元素为N个互不相同的整数,找出数组A中所有和等于K的数对.例如K = 8,数组A ...

  9. Sparse Graph---hdu5876(set+bfs+补图求最短路)

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5876 题意:有一个含有n个点的无向图,已知图的补图含有m条边u, v:求在原图中,起点s到 ...

  10. fdisk 分区

    使用fdisk对SD卡进行从新分区.步骤如下: 1. 查看分区情况 ## sudo fdisk -l Disk /dev/sda: 107.4 GB, 107374182400 bytes 255 h ...