模拟select框
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
*{
margin:0;
padding:0;
}
.link-box{
position: relative;
margin-left: 14px;
width:365px;
height:37px;
border:1px solid #cccccc;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
background-color: #fff;
}
.cur-link{
float:left;
width:318px;
height:37px;
line-height: 37px;
color:#cccccc;
text-indent: 120px;
}
.link-list{
display: none;
position: absolute;
left:0;
top:37px;
width:317px;
border:1px solid #cccccc;
overflow: hidden;
}
.link-list li{
width:316px;
height:37px;
line-height: 37px;
text-indent: 120px;
background-color: #fff;
}
.link-list li a{
text-decoration: none;
color:#cccccc;
}
.arrow-btn{
cursor: pointer;
float:left;
display: block;
width:43px;
height:37px;
border-left:1px solid #cccccc;
background: url(../img/arrow-btn.png) no-repeat center center;
} </style>
<script src="./js/jquery-1.11.3.min.js"></script>
</head>
<body>
<div class="link-box">
<div class="cur-link">更多链接</div>
<ul class="link-list">
<li><a href="javascript:void(0)">更多链接1</a></li>
<li><a href="javascript:void(0)">更多链接2</a></li>
<li><a href="javascript:void(0)">更多链接3</a></li>
</ul>
<span class="arrow-btn"></span>
</div> <script>
$(function(){
var listLength = $(".link-list li").length * 37;
$(".link-list").hide();
$(".arrow-btn").click(function(e){
$(".link-list").slideToggle(500);
$(document).one("click", function(){
$(".link-list").hide();
});
e.stopPropagation();
});
$(".link-list li").click(function(e){
var curText = $(this).find('a').text();
$(".cur-link").html(curText);
$(".link-list").hide();
e.stopPropagation();
});
})
</script>
</body>
</html>

注意:如果要实现点击a后其内容显示在select框内,需要禁止a标签的自动跳转
模拟select框的更多相关文章
- 模拟select样式,自定义下拉列表为树结构
效果图如下: 首先,需要用到的库jQuery,zTree(官网API:http://www.treejs.cn/v3/api.php) 注意:因为zTree是基于jQuery的,所以应该先引入jQue ...
- jquery实现模拟select下拉框效果
<IGNORE_JS_OP style="WORD-WRAP: break-word"> <!DOCTYPE html PUBLIC "-//W3C// ...
- ul -- li 模拟select下拉框
在写项目中 用到下拉框,一般用 <select name="" id=""> <option value=</option> &l ...
- div 模拟<select>事件
IE7 下,不能够自定义<select>/<option>的样式,所以为了方便起见,用div可以进行模拟 <!doctype html> <html> ...
- Selenium(七):选择框(radio框、checkbox框、select框)
1. 选择框 本章使用的html代码: <!DOCTYPE html> <html lang="en"> <head> <meta cha ...
- layui问题之模拟select点击事件
一.问题 不操作页面,实现模拟select的事件,即,自动出现下拉框,自动点击下拉框的值,select文本框的值随之改变 二.经过 刚开始查看layui官方文档,发现仅仅只是有select监听事件,即 ...
- 用纯css改变下拉列表select框的默认样式(不兼容IE10以下)
在这篇文章里,我将介绍如何不依赖JavaScript用纯css来改变下拉列表框的样式. 事情是这样的,您的设计师团队向您发送一个新的PSD(Photoshop文档),它是一个新的网站的最终设计 ...
- 用纯css改变下拉列表select框的默认样式
http://ourjs.com/detail/551b9b0529c8d81960000007 在这篇文章里,我将介绍如何不依赖JavaScript用纯css来改变下拉列表框的样式. 问题的提出 事 ...
- jQuery插件:模拟select下拉菜单
没搞那么复杂,工作中,基本够用.. <!doctype html> <html> <head> <meta charset="utf-8" ...
随机推荐
- (五)SpringMVC之使用Kaptcha实现验证码功能
一.什么是Kaptcha Kaptcha是Google开发的用于自动生成验证码的插件. 二.怎么导入Kaptcha ① 如果没有用Maven管理工具的话就直接导入包(可以直接下载:pau8) http ...
- Mandelbrot图像
using System;using System.Collections.Generic;using System.Text; namespace ConsoleApplication3{ ...
- leetcode 105. Construct Binary Tree from Preorder and Inorder Traversal,剑指offer 6 重建二叉树
不用迭代器的代码 class Solution { public: TreeNode* reConstructBinaryTree(vector<int> pre,vector<in ...
- Stream great concerts wherever you are
This time of year, we take stock of what we're thankful for — and above all else, we’re thankful for ...
- 01_13_Struts_默认Action
01_13_Struts_默认Action 1. 配置struts默认Action <package name="default" namespace="/&quo ...
- Java中的==和equals的区别详解
1.基础知识 (1)String x = "hello"; (2)String x = new String ("hello"); 第1种方式的工作机制是,首先 ...
- UVa 12171 题解
英文题面不怎么友好,大家还是自行通过紫书了解题面吧... 解题思路: 1. 面对500 ^ 3的数据范围,我们需要先用离散化解决掉爆空间的问题. 2. 由于我们要求的总体积包括内空部分的体积,我们可以 ...
- redis cluster 配置
#服务器192.168.56.111 192.168.56.112 192.168.56.113 计划1主2从 192.168.56.111 192.168.56.112 192.168.56.1 ...
- 201621123080《Java程序设计》第十一周学习总结
201621123080<Java程序设计>第十一周学习总结 1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多线程相关内容. 2. 书面作业 本次PTA作业题集多线程 ...
- C#基础-数组-ArrayList
数组ArrayList using System.Collections; //表示引入集合的命名空间 数组ArrayList容量本身是不固定的,根据存储的数据动态变化 // 声明一个ArrayLis ...