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 各个类 ...
随机推荐
- [SHELL进阶] (转)最牛B的 Linux Shell 命令 (四)
1.查看ASCII码表 man 7 ascii 很多人初学编程都会接触到ascii码的概念,有时候为了查某个符号的ascii值,可能还得翻箱倒柜找出当年的课本?Linux Manpage里面其实包含 ...
- 云计算中心网络资源分配-Faircloud: sharing the network in cloud computing
网络资源同计算资源以及存储资源一样,是一种可被租户共享使用并提高利用率的资源.但是,不同租户的计算资源以及存储资源之间,有很强的隔离性,可以实现按需按比例分配的使用方式,但是网络资源却不可以. 主要原 ...
- LR中日志设置和日志函数
LR中日志参数的设置与使用 1.Run-Time Setting日志参数的设置 在loadrunner的vuser菜单下的Run-Time Setting的General的LOG选项中可以对在执行脚本 ...
- Java中方法的覆写
所谓方法的覆写override就是子类定义了与父类中同名的方法,但是在方法覆写时必须考虑权限,即被子类覆写的方法不能拥有比父类方法更加严格的访问权限. 修饰符分别为public.protected.d ...
- 【转】Unity3D的输入(Input)——键盘和鼠标
http://blog.csdn.net/lingyun_blog/article/details/41451565 Unity3D使用input类控制用户的输入,输入包括了用户键盘,鼠标,触摸,重力 ...
- extjs MVC模式的个人看法
针对一个后台管理页面是mvc模式,后台也是mvc模式下的项目,要怎么去熟悉呢? 首先以我个人的认解,先从后台的管理界面来看,会有control,model,store,view:其中先看view的代码 ...
- Abstract Algebra chapter 7
7.7:Encrypt each of the following RSA messages x so that x is divided into blocks of integers of len ...
- zepto源码--isEmptyObject,isNumeric,inArray,trim--学习笔记
1.isEmptyObject,判断对象是否为空对象的函数 定义变量name,遍历传入对象的属性name,如果存在任何属性,则返回false,判定传入的参数为非空对象,否则即为空对象. 2.isNum ...
- aspx后台页面添加服务器控件
System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); System.IO.StringWriter st ...
- 1011 最大公约数GCD
1011 最大公约数GCD 基准时间限制:1 秒 空间限制:131072 KB 输入2个正整数A,B,求A与B的最大公约数. Input 2个数A,B,中间用空格隔开.(1<= A,B < ...