.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

  1.      //普通模式
  2.  
  3.       new SelectorJS.selector.init({
  4.  
  5.         id:'#Marriage',
  6.  
  7.         data: [["1", "未婚"], ["3", "离异"], ["4", "丧偶"] ],
  8.  
  9.         value:'未婚'
  10.  
  11.       });  
  12.  
  13.       //年龄联动
  14.  
  15.       new SelectorJS.age('#Age0','#Age1',25,27);
  16.  
  17.       //身高联动
  18.  
  19.       new SelectorJS.heightMulti('#Height0','#Height1',168,178);
  20.  
  21.       //地区联动 二级
  22.  
  23.       new SelectorJS.area.init('#AreaSelector','101020600', false);
  24.  
  25.       //地区联动 三级
  26.  
  27.       new SelectorJS.area.init('#AreaSelector2','101151202', true);
  28.  
  29.       //自定义联动
  30.  
  31.       var salaryCode = [["1", "1000"], ["2", "2000"], ["3", "3000"], ["4", "5000"], ["5", "8000"], ["6", "10000"], ["7", "20000"], ["8", "50000"], ["9", "50000以上"] ];
  32.  
  33.       var salaryDefault1 = '1';
  34.  
  35.       var salaryDefault2 = '4';
  36.  
  37.       new SelectorJS.selector.init({
  38.  
  39.         id:'#Salary0',
  40.  
  41.         data: salaryCode,
  42.  
  43.         value:salaryDefault1,
  44.  
  45.         click: function(val, index){
  46.  
  47.           new SelectorJS.selector.init({
  48.  
  49.             id:'#Salary1',
  50.  
  51.             data: salaryCode.slice(index),
  52.  
  53.             value:  Math.max(salaryCode[index][0], parseInt(salaryDefault2) )
  54.  
  55.           }).select.click();
  56.  
  57.         }
  58.  
  59.       }); 
  60.  
  61.       new SelectorJS.selector.init({
  62.  
  63.             id:'#Salary1',
  64.  
  65.             data: salaryCode.slice(parseInt(salaryDefault1)),
  66.  
  67.             value:  salaryDefault2
  68.  
  69.       }); 

说明

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. Firefox 在LR录制过程中添加例外的问题解决方法

    用lr调火狐打开网页  会报证书安全问题 证书安全提示目的是告诉你这个服务器使用的证书可能不安全,要不要信任,你自己决定,不信任就不能访问.为什么会报证书安全,因为浏览器没添加该证书.或者由于性能工具 ...

  2. struts 标签 牛逼之处

    <s:hidden>标签的value属性的类型是String类型,所以把<s:property value="#session.LOGIN_USER"/>当 ...

  3. (转)S5PV210 三个Camera Interface/CAMIF/FIMC的区别

    原文出处:http://blog.csdn.net/kickxxx/article/details/7728947 S5PV210有三个CAMIF单元,分别为CAMIF0 CAMIF1和CAMIF2. ...

  4. 10个最佳的触控手式的JavaScript框架(转)

    由于各种原因移动开发是一项艰难的工作,比如它是非常耗时的.充满压力的任务.最重要的是,作为一个开发人员,你必须保持更新所有最新 的技术和技巧——你必须知道所有最新的趋势,问题和解决方案等.例如跨浏览器 ...

  5. websocke前世今生

    注:以下内容来自网上.本人经过加工整理. 1.问什么要用websocke? Browser已经支持http协议,为什么还要开发一种新的WebSocket协议呢?我们知道http协议是一种单向的网络协议 ...

  6. HDU 1556 Color the ball 树状数组 题解

    Problem Description N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的"小飞鸽"牌电动 ...

  7. R语言barplot绘图函数

    barplot 函数用于绘制柱状图,下面对其常用的参数进行一个详细的解释: 1)height : 高度,通过这个参数可以指定要画多少个柱子以及每个柱子的高度,其值有两种格式, 第一种 :向量 vect ...

  8. VC++ ToolTip的简单使用

    1.在基于对话框的MFC应用程序中使用Tooltip,首先在Dlg类的头文件中定义一个变量: CToolTipCtrl m_iToolTips; 2.在Dlg类的OnInitDialog中添加代码: ...

  9. php 在windows下配置虚拟目录的方法

    1.先找到apache的配置文件 httpd.conf 找如如下代码: # Virtual hosts#Include conf/extra/httpd-vhosts.conf 把# Include ...

  10. implode,explode的使用

    implode把数组转成字符串的函数,在组合SQL语句时候使用特好使! 比如 $a = array('a','b','c');$b = implode(',', $a);echo $b; 返回的字符串 ...