JQ模仿select
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script><script src="http://upcdn.b0.upaiyun.com/libs/modernizr/modernizr-2.6.2.min.js" type="text/javascript"></script>
<script src="Jselect.js" type="text/javascript"></script>
<style>
*, html {
margin: 0;
padding: 0;
}
#body {
width: 460px;
margin: 0 auto;
height: 300px;
padding: 5%;
}
ul, li {
list-style: none;
}
#select {
height: auto;
width: 134px;
text-align: center;
border: #a1bcd1 1px solid;
}
#select .first {
background: url(http://cqcmxy.com:81/Content/Image/icobg_1.4.png) -77px -112px;
margin-bottom: 2px;
display:block;
}
#select li {
width: 134px;
height: 20px;
line-height: 25px;
cursor: pointer;
}
#select ul li {
display: none;
width: 134px;
}
</style>
</head> <body>
<div id="body">
<div id="select"> <span class="first">1</span>
<input type="hidden" value=""/>
<ul>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</div>
</div>
<script type="text/javascript">
$("#select").Jselect();
</script>
</body>
</html>
$.fn.extend({
Jselect:function(){
var me=$(this);
var li=me.find("li");
var span=me.find("span");
var hidden=me.find("input[type=hidden]");
me.hover(function(){li.show(); span.css({backgroundPosition:"-77px -143px"})},function(){li.hide(); span.css({backgroundPosition:"-77px -113px"})})
li.hover(function(){
$(this).css({background:"blue",color:"#fff"});
},function(){
$(this).css({backgroundColor:"",color:""});
})
li.click(function(){
me.find("span").html($(this).text());
hidden.val($(this).text());
})
}
})
JQ模仿select的更多相关文章
- jq bootstrap select 点击不能动弹
jq bootstrap select 点击不能动弹 因为是样式selectpicker 冲突. 解决办法换 样式 form-control <select name="ty ...
- jq操作select集合
jq操作select集合 时间:2012年12月07日分类:Javascript 最近一段时间发现,老是要跟select,option相关的东西打交道,而且有的时候还会搞错,于是,抽了一点时间整理了一 ...
- jQ的select事件和trigger方法的小冲突
方法和事件都不难理解,分开用也都没问题,但是一起用就有些小问题出现. 直接上结论:使用trigger方法触发一个文本类型的 input 元素的select事件时,chrome浏览器会错误的触发三次,f ...
- div模仿select效果二:带搜索框
项目需要,要做一个首字母快速定位的select,代码如下: HTML <div class="select_country" unselectable="on&qu ...
- JQ获取select上的option的data-start和data-id
来源:https://zhidao.baidu.com/question/692142321436883524.html 静态的写法: 用jq的attr()函数,如: HTML: <select ...
- JQ仿select框
点击[cy_title]后弹出[cy_list]层,选中里面的元素把值赋给 [cy_title] 在[cy_list] 打开的时候,点击其他地方可以关闭: HTML: <div class=&q ...
- input和div模仿select,带输入提示
有时候我们需要select和input的结合体,即可以使用下拉框,同时也可以用来输入,输入的同时显示可选的下拉选项 先上html代码 <div class="input-group i ...
- jq 操作select
添加option $("#ID option").each(function(){if($(this).val()==111){$(this).remove();}}); 移除op ...
- JQ操作select项
jQuery获取Select元素,并选择的Text和Value: 1. $("#select_id").change(function(){//code...}); //为Se ...
随机推荐
- spring quartz的触发器CrontriggerBean配置
每一个quartz的CronTrigger表达式分为七个子表达式,每个子表达式之间用空号分割,分别是:秒 分 时 日 月 星期 年.其中年不是必须的,所以CronTrigger最少有六个子表达式. 每 ...
- linux学习记录(第六章、Linux 的文件权限与目录配置)
书看的是鸟哥的私房菜,系统用的是centos.被微软坑了N年才发现linux才是王道. 在这里记录些学习的记录.备忘
- JS设置打印页面并调用本地打印机打印页面
<script type="text/javascript"> var hkey_key; var hkey_root = "HKEY_CURRENT_USE ...
- 百度编辑器1.4.3 .net版在vs2008的使用方法
由于在官方下载的ueditor包是在vs2012下开发的,可以在vs2010中使用,但在vs2008中就会报错.折腾了一翻,现将解决方法分享给需要的朋友,其实就是把里面包含.net4.0的元素换成.n ...
- 关于安卓应用(APK文件)的二次打包
http://blog.csdn.net/baiyuliang2013/article/details/40426681 很多开发者,不管是个人或是公司都不太注重自己开发的应用的安全性,即是 否会被不 ...
- iOS 图片按比例压缩,指定大小压缩
使用系统方法UIImageJPEGRepresentation(UIimage *image,CGFloat quality)进行图片质量压缩,暂且叫参数quality为压缩比吧,取值范围为0-1. ...
- EIGamal密码体制
EIGamal密码体制:由EIGamal提出,是一种基于离散对数问题的双钥密码体制,既可用于加密,又可以用于签名. 密钥对生成步骤: 1.取大素数p和g<p(g最好是p的素根) 2.选一整数x& ...
- RSA安全性问题
加密:C=Me(mod n) 解密:M=Cd(mod n) 安全性基础: 穷举法攻击: 1.攻击者设计一个M,C=Me(mod n) 2.d的个数至多有n-1个,尝试使用每个d破解,如果M’=Cd‘( ...
- Docker之配置Centos_ssh
写Dockerfile配置文件 #DockerfileFROM centos:6 #以下命令用在什么镜像中MAINTAINER cuizhipeng <cuizhipeng@126.com&g ...
- CentOS 5.4 制作 Python 2.6 RPM 包的方法
不知道什么原因,CentOS 5.4 了,默认的Python的版本还是2.4的. 但是Python在CentOS里面的又非常的重要,可是 2.4版本的Python有很多的模块没有,最新的Python ...