<!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的更多相关文章

  1. jq bootstrap select 点击不能动弹

    jq  bootstrap select 点击不能动弹   因为是样式selectpicker  冲突. 解决办法换 样式  form-control <select name="ty ...

  2. jq操作select集合

    jq操作select集合 时间:2012年12月07日分类:Javascript 最近一段时间发现,老是要跟select,option相关的东西打交道,而且有的时候还会搞错,于是,抽了一点时间整理了一 ...

  3. jQ的select事件和trigger方法的小冲突

    方法和事件都不难理解,分开用也都没问题,但是一起用就有些小问题出现. 直接上结论:使用trigger方法触发一个文本类型的 input 元素的select事件时,chrome浏览器会错误的触发三次,f ...

  4. div模仿select效果二:带搜索框

    项目需要,要做一个首字母快速定位的select,代码如下: HTML <div class="select_country" unselectable="on&qu ...

  5. JQ获取select上的option的data-start和data-id

    来源:https://zhidao.baidu.com/question/692142321436883524.html 静态的写法: 用jq的attr()函数,如: HTML: <select ...

  6. JQ仿select框

    点击[cy_title]后弹出[cy_list]层,选中里面的元素把值赋给 [cy_title] 在[cy_list] 打开的时候,点击其他地方可以关闭: HTML: <div class=&q ...

  7. input和div模仿select,带输入提示

    有时候我们需要select和input的结合体,即可以使用下拉框,同时也可以用来输入,输入的同时显示可选的下拉选项 先上html代码 <div class="input-group i ...

  8. jq 操作select

    添加option $("#ID option").each(function(){if($(this).val()==111){$(this).remove();}}); 移除op ...

  9. JQ操作select项

    jQuery获取Select元素,并选择的Text和Value: 1. $("#select_id").change(function(){//code...});   //为Se ...

随机推荐

  1. Linux环境下搭建Android开发环境

    最近在折腾linux.因为咱是搞安卓开发的,所以少不了需要搭建Android开发环境,就此小记,希望能给向我一样的开发者一点帮助!开干! 1.安装JDK 下载JDK包,得到的是类似于jdk-8u65- ...

  2. 在iframe中获取父页面的元素

    a.html <!DOCTYPE html> <html> <head> <title></title> </head> < ...

  3. [ lucene高级 ] 研讨如何进行Lucene的分布式应用

    http://www.cnblogs.com/huangfox/archive/2010/10/15/1852206.html Lucene是个高度优化的倒转索引搜索引擎.它将倒转的索引存储在定制的文 ...

  4. 快速预览:C# 3.0的新东西

    Lambda 表达式: Func<string, string> doubleAppend= x => x + x; Console.WriteLine (doubleAppend( ...

  5. 20151221jquery学习笔记--验证插件

    验证插件(validate.js),是一款验证常规表单数据合法性的插件.使用它,极大的解放了在表单上繁杂的验证过程,并且错误提示显示的完善也增加了用户体验.一. 使用 validate.js 插件官网 ...

  6. Android----二维码开发

    Android----二维码开发 本文为原创,转载请注明出处:http://www.cnblogs.com/xiaobaicai12138/p/5644244.html 一.工具 谷歌的zxing 不 ...

  7. 一些VR延迟优化方法

    http://m.blog.csdn.net/article/details?id=50667507 VR中的”延迟”, 特指”Motion-To-Photon Latency”, 指的是从用户运动开 ...

  8. Java NIO 选择器(Selector)的内部实现(poll epoll)

    http://blog.csdn.net/hsuxu/article/details/9876983 之前强调这么多关于linux内核的poll及epoll,无非是想让大家先有个认识: Java NI ...

  9. 自己在使用的English词典

    一.ESL/非母语词典 二.EFL/母语词典 1.American Heritage Dictionary 2.World Book Dictionary 3.Oxford Dictionary of ...

  10. ISO 学习笔记 2015-03-15

    Objective--C 一 关键字 @property 定义变量函数 @synthesize 实现变量函数 二 函数 alloc 分配内存 init 初始化 new 替代上面两个函数 分配内存,并且 ...