.m-form{background:#fff;padding:50px;font-family:12px/1.5 arial,\5b8b\4f53,sans-serif;}
.m-form ul,.m-form li,.m-form dl,.m-form dt,.m-form dd{padding:0;margin:0;list-style:none;}
.m-form label{color:#6E6E6E;display:inline-block;height:36px;float:left;line-height:36px;width:120px;text-align:right;padding-right:20px;}
.m-form .item{height:46px;margin-bottom:10px;}
.m-form .t{display:block;height:36px;line-height:36px;padding:0 10px;float:left;}
.m-select{height:36px;float:left;width:234px;background-image:url(http://dreamback.github.io/selectorjs/src/images/selector.png);background-repeat:no-repeat;background-position:100% 0;border-radius: 5px;}
.m-select-w{width:100px;}
.m-focus{background-position:100% 100%;position:relative;}
.m-select dt{line-height:32px;border:2px solid #E3E3E3;text-align:center;text-indent:-31px;cursor:pointer;height:32px;border-radius: 5px;}
.m-select dd{width:100%;overflow-y:auto;background:#fff;position:absolute;left:0;top:34px;display:none;border-top:2px solid #E3E3E3;border-bottom:2px solid #E3E3E3;border-radius: 5px;box-shadow:0 6px 12px rgba(0,0,0,0.175)}
.m-select dd a{display:block;font-size:14px;text-indent:1em;line-height:32px;border-right:2px solid #E3E3E3;border-left:2px solid #E3E3E3;height:32px;}
.m-select dd a:hover{text-decoration:none;background:#eee;}
.m-select dd.age,.m-select dd.height{width:400px;border:2px solid #E3E3E3;}
.m-select dd.age a,.m-select dd.height a{float:left;width:40px;text-align:center;border:none;display:inline-block;text-indent:0;height:24px;line-height:24px;}
.m-select dd.region{width:460px;height:200px;border:2px solid #E3E3E3;}
.region .tab{height:28px;padding:10px 0 0 10px;}
.region .tab li{float:left;height:24px;line-height:24px;padding:0 20px;border:1px solid #E3E3E3;margin-right:5px;cursor:pointer;}
.region .tab li.on{border:2px solid #7DB3D4;cursor:default;position:relative;background:#7DB3D4;color:#fff;}
.region .tab-con{border-top:2px solid #7DB3D4;margin:0 10px 10px 10px;position:relative;top:-2px;background:#fff;}
.m-select dd.region a{float:left;text-align:center;border:none;width:62px;overflow:hidden;overflow:hidden;display:inline-block;text-indent:0;}
.m-form .form-item{position:static;margin-bottom:200px;}

通过JS模拟select表单,达到美化效果

Demo

婚姻状况:
未婚
年龄:

身高:

居住地:
出生地:
月收入:

Code

              //普通模式

               new SelectorJS.selector.init({

                 id:'#Marriage',

                 data: [["1", "未婚"], ["3", "离异"], ["4", "丧偶"] ],

                 value:'未婚'

               });  

               //年龄联动

               new SelectorJS.age('#Age0','#Age1',25,27);

               //身高联动

               new SelectorJS.heightMulti('#Height0','#Height1',168,178);

               //地区联动 二级

               new SelectorJS.area.init('#AreaSelector','101020600', false);

               //地区联动 三级

               new SelectorJS.area.init('#AreaSelector2','101151202', true);

               //自定义联动

               var salaryCode = [["1", "1000"], ["2", "2000"], ["3", "3000"], ["4", "5000"], ["5", "8000"], ["6", "10000"], ["7", "20000"], ["8", "50000"], ["9", "50000以上"] ];

               var salaryDefault1 = '1';

               var salaryDefault2 = '4';

               new SelectorJS.selector.init({

                 id:'#Salary0',

                 data: salaryCode,

                 value:salaryDefault1,

                 click: function(val, index){

                   new SelectorJS.selector.init({

                     id:'#Salary1',

                     data: salaryCode.slice(index),

                     value:  Math.max(salaryCode[index][0], parseInt(salaryDefault2) )

                   }).select.click();

                 }

               }); 

               new SelectorJS.selector.init({

                     id:'#Salary1',

                     data: salaryCode.slice(parseInt(salaryDefault1)),

                     value:  salaryDefault2

               }); 
         

说明

Selector.js与address.json两个文件必须放在同一个目录下。当调用地区的方法的时候才加载adrress文件

github下载地址:http://dreamback.github.io/selectorjs/index.html

通过JS模拟select表单,达到美化效果[demo]的更多相关文章

  1. 通过JS模拟select表单,达到美化效果[demo][转]

    转自: http://www.cnblogs.com/dreamback/p/SelectorJS.html 通过JS模拟select表单,达到美化效果 Demo ------------------ ...

  2. js模拟form表单提交数据, js模拟a标签点击跳转,避开使用window.open引起来的浏览器阻止问题

    js模拟form表单提交数据, js模拟a标签点击跳转,避开使用window.open引起来的浏览器阻止问题 js模拟form表单提交数据源码: /** * js模拟form表单提交 * @param ...

  3. js 模拟form表单post提交

    var generateHideElement = function (name, value) { var tempInput = document.createElement("inpu ...

  4. select表单元素详解及下拉列表模拟实现

    原文地址:→看过来 写在前面 select 是HTML表单元素中很常用的一个,其中很重要的几个属性常被忽略,但这几个属性却能帮助我们完成很多的功能,当然,select下拉列表默认样式很不友好,所以更多 ...

  5. div仿checkbox表单样式美化及功能

    div仿checkbox表单样式美化及功能(checkbox的样式不好看)素材在底部: 效果图: window.css .bj { position: absolute; top: 0; left: ...

  6. .Net模拟提交表单

    2016-09-0210:49:20 以中邮速递API为服务接口,由于提交方式为表单提交,我要获取返回值来处理其他业务,所以一开始尝试采用Js后台获取返回值,但是涉及到跨域请求限制问题,那边服务端接口 ...

  7. nodejs 模拟form表单上传文件

    使用nodejs来模拟form表单进行文件上传,可以同时上传多个文件. 以前项目里有这个方法,最近在客户那里出问题了,同事说,这个方法从来就没管用过,SO,用了一天时间把这个方法给搞出来了(觉得花费的 ...

  8. js_ajax模拟form表单提交_多文件上传_支持单个删除

    需求场景: 用一个input type="file"按钮上传多张图片,可多次上传,可单独删除,最后使用ajax模拟form表单提交功能提交到指定方法中: 问题:由于只有一个file ...

  9. 杂记-格式化Date默认格式,日期加一天,jstl判断字符类型,ajax模拟from表单后台跳转页面,jstl访问数据库并在页面显示

    1.格式化Date默认格式 String str="Sun Oct 08 22:36:45 CST 2017"; SimpleDateFormat sdf = new Simple ...

随机推荐

  1. 周末大礼:jQuery技巧总结

    一.简介 1.1.概述 随着WEB2.0及ajax思想在互联网上的快速发展传播,陆续出现了一些优秀的Js框架,其中比较著名的有Prototype.YUI.jQuery.mootools.Bindows ...

  2. Hibernate的getTransaction()和beginTransaction()

    session.getTransaction()只是根据session获得一个Transaction实例,但是并没有启动它 session.beginTransaction()在获得一个Transac ...

  3. C#代理多样性

    一.代理 首先我们要弄清代理是个什么东西.别让一串翻译过来的概念把大家搞晕了头.有的文章把代理称委托.代表等,其实它们是一个东西,英文表述都是“Delegate”.由于没有一本权威的书来规范这个概念, ...

  4. 测试x264编码器的低延时编码和非延时编码

    最近在学x264的编码,经过大量的测试,编码1080P的视频,编码10000帧数据. 在设置为低延时编码的时候: 编码线程0,一帧耗时:7.000000 ms.编码线程0,一帧耗时:8.000000 ...

  5. (转)学习linux的几本书

    成为一名精通 Linux 程序设计的高级程序员一直是不少朋友孜孜以求的目标.根据中华英才网统计数据,北京地区 Linux 程序员月薪平均为 Windows 程序员的 1.8 倍.Java 程序员的 2 ...

  6. 你是否有遇到过某个实体类字段(属性)过多的情况,不想每次点的话戳进来(C# 反射)

    贴上一段代码: bureaucraticEntities apply = new bureaucraticEntities(); Type tapp= app.GetType(); Type ttmp ...

  7. XP 终端服务组件 ,SP3 多用户补丁(替换)文件

    如附件 termsrv.dll   5.1.2600.5512 目前存在一个问题:每个用户只能使用一个会话.不能像2003+那样,一个用户使用多个会话. 待查找解决方案中............... ...

  8. 各大IT公司 技术博客汇总

    来自:http://www.cnblogs.com/IT-Bear/p/3191423.html 腾讯系列(13)  阿里系列(18)  百度系列(3)  搜狐系列(3)  新浪系列(2)  360系 ...

  9. sftp,get命令使用*通配符的方式获取批量的文件

    需求描述: 今天在使用sftp进行get文件的时候,有很多文件名类似的文件,以为还是需要一个一个get 后来发现get也可以使用通配符的方式进行匹配获取多个文件,在此记录下 操作过程: 1.通过sft ...

  10. [java] Unsupported major.minor version 51.0 错误解决方案

    jdk1.6工程中使用外部jar包中类出现:Unsupported major.minor version 51.0原因分析:出现上述错误是因为:外部jar包使用jdk1.7(jdk7)编译,而使用此 ...