zoukankan      html  css  js  c++  java
  • 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 {
    	 460px;
    	margin: 0 auto;
    	height: 300px;
    	padding: 5%;
    }
    ul, li {
    	list-style: none;
    }
    #select {
    	height: auto;
    	 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 {
    	 134px;
    	height: 20px;
    	line-height: 25px;
    	cursor: pointer;
    }
    #select ul li {
    	display: none;
    	 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());
    			})
    		}
    	})
    

      

  • 相关阅读:
    poj 3661
    hdu 4291 && hdu 4296
    codeforces LCM Challenge
    ural 1286
    Exhange2007 专题(一)特性 部署
    Research Http error code
    Exhange2007 专题(二)通过Web service对Exhange进行二次开发
    YouTube 架构学习体会
    .net framework 4.0环境下遇到版本不同编译不通过的解决办法
    利用ASP.NET MVC2进行网站验证
  • 原文地址:https://www.cnblogs.com/SpeakHero/p/3175686.html
Copyright © 2011-2022 走看看