jquery实现模拟select下拉框效果

- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>DIV模拟select下拉菜单</title>
- <style type="text/css">
- .mod_select{position:absolute;left:30%;top:100px;font-familY:Arial, Helvetica, sans-serif;}
- .mod_select ul{margin:0;padding:0;}
- .mod_select ul li{list-style-type:none;float:left;margin-left:20px;height:24px;}
- .select_label{color:#982F4D;float:left;line-height:24px;padding-right:10px;font-size:12px;font-weight:700;}
- .select_box{float:left;border:solid 1px #EDE7D6;color:#444;position:relative;cursor:pointer;width:165px;background:url(../select_bg.jpg) repeat-x;font-size:12px;}
- .selet_open{display:inline-block;border-left:solid 1px #E5E5E5;position:absolute;right:0;top:0;width:30px;height:24px;background:url(../select_up.jpg) no-repeat center center;}
- .select_txt{display:inline-block;padding-left:10px;width:135px;line-height:24px;height:24px;cursor:text;overflow:hidden;}
- .option{width:165px;;border:solid 1px #EDE7D6;position:absolute;top:24px;left:-1px;z-index:2;overflow:hidden;display:none;}
- .option a{display:block;height:26px;line-height:26px;text-align:left;padding:0 10px;width:100%;background:#fff;}
- .option a:hover{background:#FDE0E5;}
- </style>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
- <script type="text/javascript">
- $(document).ready(function(){
- $(".select_box").click(function(event){
- event.stopPropagation();
- $(this).find(".option").toggle();
- $(this).parent().siblings().find(".option").hide();
- });
- $(document).click(function(event){
- var eo=$(event.target);
- if($(".select_box").is(":visible") && eo.attr("class")!="option" && !eo.parent(".option").length)
- $('.option').hide();
- });
- /*赋值给文本框*/
- $(".option a").click(function(){
- var value=$(this).text();
- $(this).parent().siblings(".select_txt").text(value);
- $("#select_value").val(value)
- })
- })
- </script>
- </head>
- <body>
- <div class="mod_select">
- <ul>
- <li>
- <span class="select_label">sort buy:</span>
- <div class="select_box">
- <span class="select_txt"></span><a class="selet_open"><b></b></a>
- <div class="option">
- <a>1</a>
- <a>2</a>
- <a>3</a>
- </div>
- </div>
- <br clear="all" />
- </li>
- <li>
- <span class="select_label">View:</span>
- <div class="select_box">
- <span class="select_txt"></span><a class="selet_open"></a>
- <div class="option">
- <a>1</a>
- <a>2</a>
- <a>3</a>
- </div>
- </div>
- </li>
- </ul>
- <input type="hidden" id="select_value" />
- </div>
- </body>
- </html>
复制代码
jquery实现模拟select下拉框效果的更多相关文章
- jquery选中将select下拉框中一项后赋值给text文本框
jquery选中将select下拉框中一项后赋值给text文本框,出现无法将第一个下拉框的value赋值给文本框 因为select默认选中第一项..在选择第一项时,便导致无法激发onchange事件. ...
- jquery取消选择select下拉框
有三个select下拉框一个大类,两个小类隐藏,需要在选择大类的时候,小类显示同时清除另外的小类选择的项这需求有点儿.......... 下面是三个select: <select name=&q ...
- jQuery插件实现select下拉框左右选择_交换内容(multiselect2side)
效果图: 使用jQuery插件---multiselect2side做法: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitio ...
- 一款基于jQuery的联动Select下拉框
今天我们要来分享一款很实用的jQuery插件,它是一个基于jQuery多级联动的省市地区Select下拉框,并且值得一提的是,这款联动下拉框是经过自定义美化过的,外观比浏览器自带的要漂亮许多.另外,这 ...
- jQuery操作选中select下拉框的值
js和jQuery联合操作dom真的很好用,如果不是专业前端人员的话,我觉得吧前端语言只要熟练掌握js和jQuery就可以了. 获取select下拉框的几种情况如下: 1.获取第一个option的值 ...
- jq插件又来了,模拟select下拉框,支持上下方向键哦
好久没来了,更新下插件, 这个原理就是利用的 input[type='hidden']和自定义属性data-value捆绑传值操作的,可是设置默认选项,回调等参数,代码不多,比较简单,吼吼 (func ...
- 用div,ul,input模拟select下拉框
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- ul -- li 模拟select下拉框
在写项目中 用到下拉框,一般用 <select name="" id=""> <option value=</option> &l ...
- jQuery动态生成<select>下拉框
前一阵在项目里需要动态生成下拉框,找了一下用jQuery实现比较方便,这里整理一下. 下文所述方法只是本人在项目中遇到问题的解决方法,场景较为简单,也希望能帮助有需要的朋友 1.动态生成下拉框的两种方 ...
随机推荐
- Spring+Junit测试用例的使用
1.[导包]使用Spring测试套件,需要两个jar包:junit-X.X.jar和spring-test-X.X.X.RELEASE.jar,在maven项目下可添加如下依赖: <depend ...
- [转帖]SSL/TLS/WTLS原理
SSL/TLS/WTLS原理 作者:yawl < yawl@nsfocus.com >主页:http://www.nsfocus.com日期:2001-02-19 一 前言 首先要澄清一下 ...
- Java 策略模式(Strategy)
创建一个能够根据所传递的参数对象的不同而具有不同行为的方法 要执行的算法固定不变,封装到一个类(Context)中 策略就是传递进去的参数对象,它包含执行代码 策略接口 /** * 策略接口 */ p ...
- sqlserver2017安装及连接过程中发现的问题
1.SSMS安装报错,如下图 根据搜索资料发现是防火墙的问题,关闭防火墙就行了. 2.连接用户时报错 这个是因为远程连接相关问题. 首先打开服务器远程连接: 其次点击: SqlServer配置管理器- ...
- spring MVC 统一异常处理(webapi和web分开处理)
转载: http://blog.csdn.net/m13321169565/article/details/7641978 http://blog.csdn.net/ethan_fu/article/ ...
- The Applications of RT-Thread RTOS
The Applications of RT-Thread RTOS Introduction The user application is the application layer of RT- ...
- linux运维之分析系统负载及运行状况
1.删除0字节文件 find -type f -size -exec rm -rf {} \; 2.查看进程 #按内存从大到小排列 ps -e -o "%C : %p : %z : %a&q ...
- 解题:CF1130E Wrong Answer
题面 巧妙构造题 这种题一定要限制一个条件,使得在这个条件下能推出要叉的代码的式子 令序列$a$的第一个元素为负,其余元素为正,且保证序列中至少有两个元素,那么Alice的代码将会从第二个元素开始计算 ...
- 【洛谷P1330】封锁阳光大学
题目大意:给定一个 N 个点,M 条边的无向图,现在要选出图中的一个顶点集合,使得集合种的顶点不直接相邻,且这张图的所有边都被该顶点集合覆盖,求该顶点集合大小的最小值,若不能完成覆盖,则输出 impo ...
- c++并发编程之条件变量(Condition Variable)
条件变量(Condition Variable)的一般用法是:线程 A 等待某个条件并挂起,直到线程 B 设置了这个条件,并通知条件变量,然后线程 A 被唤醒.经典的「生产者-消费者」问题就可以用条件 ...