模拟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" ...
随机推荐
- nfs-ganesha使用
一 nfs-ganesha在centos7上安装 yum -y install centos-release-gluster yum install -y nfs-ganesha.x86_64yum ...
- 【0624作业】使用Scanner类输入并显示会员卡号
package com.work0624; /** * 练习题 * 使用Scanner类输入并显示会员卡号 * @author L */ import java.util.Scanner; publi ...
- 数据结构C语言实现系列——线性表(单向链表)
#include <stdio.h> #include <stdlib.h> #define NN 12 #define MM 20 typedef int elemType ...
- 浅谈一类「AC自动机计数」问题
最近写了几道AC自动机的题.这几题主要考察的是对AC自动机的浅层理解套上计数. 几道计数题 [AC自动机]bzoj3172: [Tjoi2013]单词 把被动贡献看成主动贡献. [状态压缩dp]119 ...
- Flask-蓝图、模型与CodeFirst
一.应用.蓝图与视图函数 结构,如图: Flask最上层是app核心对象 ,在这个核心对象上可以插入很多蓝图,这个蓝图是不能单独存在的,必须将app作为插板插入app ,在每一个蓝图上,可以注册很多静 ...
- mybatis枚举类型处理器
1. 定义枚举值的接口 public abstract interface ValuedEnum { int getValue(); } 所有要被mybatis处理的枚举类继承该接口 2. 定义枚举类 ...
- MySQL查询时,查询结果如何按照where in数组排序
MySQL查询时,查询结果如何按照where in数组排序 在查询中,MySQL默认是order by id asc排序的,但有时候需要按照where in 的数组顺序排序,比如where in的id ...
- POJ:1753-Flip Game(二进制+bfs)
题目链接:http://poj.org/problem?id=1753 Flip Game Time Limit: 1000MS Memory Limit: 65536K Description Fl ...
- Nordic Collegiate Programming Contest 2015 G. Goblin Garden Guards
In an unprecedented turn of events, goblins recently launched an invasion against the Nedewsian city ...
- 求数组中两两相加等于20的组合(Python实现)
题目 求数组中两两相加等于20的组合. 例:给定一个数组[1, 7, 17, 2, 6, 3, 14],这个数组中满足条件的有两对:17+3=20, 6+14=20. 解析 分为两个步骤: 先采用堆排 ...