<!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. Storm集群扩容——从单机模式拓展到集群模式,以此类推

    Storm是分布式的实时流处理系统,单机模式肯本不能体现其强大特点,尤其是当需要处理的数据很大很快的 时候,Storm可以随时扩容,而且操作非常简单,编写的应用程序自动负载均衡. 前面已经介绍了如何安 ...

  2. DS4700存储日志收集

      a)DS4700存储日志收集              1)收集all support data 1.1.启动客户端”DS Storage manger 10 client”添加控制器IP”192 ...

  3. 安卓数据存储(3):SQLite数据库存储

    SQLite简介 Google为Andriod的较大的数据处理提供了SQLite,他在数据存储.管理.维护等各方面都相当出色,功能也非常的强大.SQLite具备下列特点: 1.轻量级:使用 SQLit ...

  4. Css样式之overflow

    1:overflow属性的可能取值有4种:visible,hidden,scroll,和auto 1) visible:不裁剪溢出的内容.浏览器将把溢出的内容呈现在其容器的显示区域之外,全部内容都可见 ...

  5. mysql自增

    主键设置自增,同时主键需要是int类型

  6. NUnit使用详解(二)

    转载:http://hi.baidu.com/grayworm/item/39aa11c5d9375d56bdef6990 五:常用断言 在NUnit中,断言是单元测试的核心.NUnit提供了一组丰富 ...

  7. 关于MySQL中使用LOAD DATA INFILE导入csv文件时的日期格式问题

    在使用MySQL时,常常会用到Load Data Infile来导入数据,在遇到Date类型的列时,有时会遇到格式转换的问题: 首先创建一张简单的people表,包含名字,生日,年龄三个字段: mys ...

  8. CustomEditor的文件要放在Assets/Editor目录下

    using UnityEditor; using UnityEngine; [CustomEditor(typeof(test))] public class testEditor : Editor ...

  9. 数据挖掘-关联规则分析[ZZ]

    1.什么是关联规则 "尿布与啤酒"的故事大家都有听过,这里就不罗嗦了. 按常规思维,尿布与啤酒风马牛不相及,若不是借助数据挖掘技术对大量交易数据进行挖掘分析,沃尔玛是不可能发现数据 ...

  10. 九度OJ 1433 FatMouse -- 贪心算法

    题目地址:http://ac.jobdu.com/problem.php?pid=1433 题目描述: FatMouse prepared M pounds of cat food, ready to ...