使用CSS和jQuery 模拟select
来源:互联网 发布:apache linux版本下载 编辑:程序博客网 时间:2024/06/07 03:50
模拟select 并带有提交后取得数据的代码
演示
XML/HTML Code
- <div id="dropdown">
- <p>请选择城市</p>
- <ul>
- <li><a href="#" rel="2">北京</a></li>
- <li><a href="#" rel="3">上海</a></li>
- <li><a href="#" rel="4">武汉</a></li>
- <li><a href="#" rel="5">广州</a></li>
- </ul>
- </div>
- <div id="result"></div>
JavaScript Code
- <script type="text/javascript">
- $(function(){
- $("#dropdown p").click(function(){
- var ul = $("#dropdown ul");
- if(ul.css("display")=="none"){
- ul.slideDown("fast");
- }else{
- ul.slideUp("fast");
- }
- });
- $("#dropdown ul li a").click(function(){
- var txt = $(this).text();
- $("#dropdown p").html(txt);
- var value = $(this).attr("rel");
- $("#dropdown ul").hide();
- $("#result").html("您选择了"+txt+",值为:"+value);
- });
- });
- </script>
CSS Code
- #dropdown{width:186px; margin:100px auto; position:relative}
- #dropdown p{width:150px; height:24px; line-height:24px; padding-left:4px; padding-right:30px; border:1px solid #a9c9e2; background:#e8f5fe url(arrow.gif) no-repeat rightright 4px; color:#807a62; cursor:pointer}
- #dropdown ul{width:184px; background:#e8f5fe; margin-top:2px; border:1px solid #a9c9e2; position:absolute; display:none}
- #dropdown ul li{height:24px; line-height:24px; text-indent:10px}
- #dropdown ul li a{display:block; height:24px; color:#807a62; text-decoration:none}
- #dropdown ul li a:hover{background:#c6dbfc; color:#369}
- #result{margin-top:10px;text-align:center}
原文地址:http://www.freejs.net/article_biaodan_60.html
- 使用CSS和jQuery 模拟select
- 使用jquery模拟select下拉框
- jQuery 模拟select
- jquery模拟SELECT框
- jquery模拟select
- jquery-模拟打开select
- 使用div+css模拟select功能与效果
- Jquery对select 和option 的使用
- jQuery模拟Select下拉框
- jquery模拟select下拉框
- JQuery SELECT单选模拟 - jQuery.select.js
- jQuery select使用
- jquery select的使用
- 使用jquery操作select
- Jquery,select使用
- 使用jQuery和CSS将背景图片拉伸
- 使用jQuery和CSS将背景图片拉伸
- 使用jQuery和CSS将背景图片拉伸
- javascript数组与字符串的互转
- python元组Tuple的遍历
- 使用grant命令新增mysql用户名和密码
- Linux C语言编程 之 线程同步机制
- PHP中include与require的用法区别
- 使用CSS和jQuery 模拟select
- Google中国2014校园招聘笔试Round B China New Grad Test Problem E. Ignore all my comments
- EasyUi_学习之路_04
- 修改git commit 除了 git commit --amend 还有 git commmit rebase, reset, .
- 0.ring3-hook-GetThreadContext注意点(获取threadcontext错误点)
- linux下读取cpu核温度。
- 让IE6支持max/min-height/width样式属性方法
- 获取二叉树第n层的节点个数
- 如何预测用户query意图