jQuery结合UL标签下拉框美化js代码

版权:原创 更新时间:1年以上
[该文章底部包含文件资源,可根据自己情况,决定是否下载资源使用,时间>金钱,如有需要,立即查看资源]

以下是 jQuery结合UL标签下拉框美化js代码 的示例演示效果:

当前平台(PC电脑)
  • 平台:

部分效果截图:

jQuery结合UL标签下拉框美化js代码

HTML代码(index.html):

<!DOCTYPE html>
<html lang="zh-CN">
	<head>
	<meta charset="UTF-8">
	<title>jQuery结合UL标签下拉框美化</title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<link rel="stylesheet" href="css/cui.css" />
	<style>
body {
	color: #555;
	font-size: 14px;
	font-family: "微软雅黑", "Microsoft Yahei";
	background-color: #EEE;
}
a {
	color: #555;
}
a:hover {
	color: #f00;
}
input {
	font-size: 14px;
	font-family: "微软雅黑", "Microsoft Yahei";
}
.wrap {
	width: 500px;
	margin: 100px auto;
}
.h20 {
	height: 20px;
	overflow: hidden;
	clear: both;
}
.nice-select {
	width: 245px;
	padding: 0 10px;
	height: 38px;
	border: 1px solid #999;
	position: relative;
	box-shadow: 0 0 5px #999;
	background: #fff url(images/a2.jpg) no-repeat right center;
	cursor:pointer;
}
.nice-select input {
	display: block;
	width: 100%;
	height: 38px;
	line-height: 38px \9;
	border: 0;
	outline: 0;
	background: none;
	cursor:pointer;
}
.nice-select ul {
	width: 100%;
	display: none;
	position: absolute;
	left: -1px;
	top: 38px;
	overflow: hidden;
	background-color: #fff;
	max-height: 150px;
	overflow-y: auto;
	border: 1px solid #999;
	border-top: 0;
	box-shadow: 0 3px 5px #999;
	z-index:9999;
}
.nice-select ul li {
	height: 30px;
	line-height: 30px;
	overflow: hidden;
	padding: 0 10px;
	cursor: pointer;
}
.nice-select ul li.on {
	background-color: #e0e0e0;
}
</style>
</head>
<body>
<div class="wrap">
    <div class="nice-select" name="nice-select">
    <input type="text" value="==选择省份==" readonly>
    <ul>
      <li data-value="1">湖北省</li>
      <li data-value="2">广东省</li>
      <li data-value="3">湖南省</li>
      <li data-value="4">四川省</li>
    </ul>
  </div>
      <div class="h20"></div>
      <div class="nice-select" name="nice-select">
    <input type="text" value="==选择城市==" readonly>
    <ul>
      <li data-value="1">武汉市</li>
      <li data-value="2">深圳市</li>
      <li data-value="3">长沙市</li>
      <li data-value="4">成都市</li>
    </ul>
  </div>
      <div class="h20"></div>
      <div class="nice-select" name="nice-select">
    <input type="text" value="==选择区县==" readonly>
    <ul>
      <li data-value="1">蔡甸区</li>
      <li data-value="2">南山区</li>
      <li data-value="3">雨花区</li>
      <li data-value="4">武侯区</li>
    </ul>
  </div>
</div>
<script type="text/javascript" src="js/jquery.js"></script> 
<script>	
$('[name="nice-select"]').click(function(e){
	$('[name="nice-select"]').find('ul').hide();
	$(this).find('ul').show();
	e.stopPropagation();
});
$('[name="nice-select"] li').hover(function(e){
	$(this).toggleClass('on');
	e.stopPropagation();
});
$('[name="nice-select"] li').click(function(e){
	var val = $(this).text();
	var dataVal = $(this).attr("data-value");
	$(this).parents('[name="nice-select"]').find('input').val(val);
	$('[name="nice-select"] ul').hide();
	e.stopPropagation();
	alert("中文值是:"+val);
	alert("数字值是:"+dataVal);
	//alert($(this).parents('[name="nice-select"]').find('input').val());
});
$(document).click(function(){
	$('[name="nice-select"] ul').hide();
});
</script>
</body>
</html>









CSS代码(cui.css):

body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td{margin:0;padding:0;}
table{border-collapse:collapse;border-spacing:0;}
fieldset,img{border:0;}
ol,ul{list-style:none;}
caption,th{text-align:left;}
q:before,q:after{content:'';}
abbr,acronym{border:0;}
.clear{clear:both;display:block;overflow:hidden;visibility:hidden;width:0;height:0;}
.l,.col-l,.col_l,.col-c,.col_c{float:left;}
.r,.col-r,.col_r,dt span,.ul-txt li span,.ul_txt li span{float:right;}
.c{clear:both;}
.n,em{font-weight:normal;font-style:normal;}
.b{font-weight:bold;}
.i{font-style:italic;}
.fa{font-family:Arial;}
.fg{font-family:Georgia;}
.ft{font-family:Tahoma;}
.fl{font-family:Lucida Console;}
.fs{font-family:'宋体';}
.fw{font-family:'微软雅黑';}
.tc{text-align:center;}
.tr{text-align:right;}
.tl{text-align:left;}
.tdu{text-decoration:underline;}
.tdn,.tdn:hover,a.tdl:hover{text-decoration:none;}
.fc0{color:#000000;}
.fc3{color:#333333;}
.fc6{color:#666666;}
.fc9{color:#999999;}
.fcr{color:red;}
.fcw{color:white;}
.fcb{color:blue;}
.fcg{color:green;}
.f0{font-size:0;}
.f10{font-size:10px;}
.f12{font-size:12px;}
.f13{font-size:13px;}
.f14{font-size:14px;}
.f16{font-size:16px;}
.f20{font-size:20px;}
.f24{font-size:24px;}
.vm{vertical-align:middle;}
.vtb{vertical-align:text-bottom;}
.vt{vertical-align:top;}
.vn{vertical-align:-2px;}
.vimg{margin-bottom:-3px;}
.m0{margin:0;}
.ml0{margin-left:0;}
.ml5{margin-left:5px;}
.ml10{margin-left:10px;}
.ml20{margin-left:20px;}
.mr0{margin-right:0;}
.mr5{margin-right:5px;}
.mr10{margin-right:10px;}
.mr20{margin-right:20px;}
.mt5{margin-top:5px;}
.mt10{margin-top:10px;}
.mt20{margin-top:20px;}
.mb5{margin-bottom:5px;}
.mb10{margin-bottom:10px;}
.mb20{margin-bottom:20px;}
.ml-1{margin-left:-1px;}
.mt-1{margin-top:-1px;}
.p1{padding:1px;}
.pl5{padding-left:5px;}
.p5{padding:5px;}
.pt5{padding-top:5px;}
.pr5{padding-right:5px;}
.pb5{padding-bottom:5px;}
.p10{padding:10px;}
.pl10{padding-left:10px;}
.pt10{padding-top:10px;}
.pr10{padding-right:10px;}
.pb10{padding-bottom:10px;}
.p20{padding:20px;}
.pl20{padding-left:20px;}
.pt20{padding-top:20px;}
.pr20{padding-right:20px;}
.pb20{padding-bottom:20px;}
.rel,.pr{position:relative;}
.abs,.pa{position:absolute;}
.dn{display:none;}
.db{display:block;}
.dib{-moz-inline-stack:inline-block;display:inline-block;}
.di{display:inline;}
.ovh{overflow:hidden;}
.ovs{overflow:scroll;}
.vh{visibility:hidden;}
.vv{visibility:visible;}
.lh14{line-height:14px;}
.lh16{line-height:16px;}
.lh18{line-height:18px;}
.lh20{line-height:20px;}
.lh22{line-height:22px;}
.lh24{line-height:24px;}
.fix{*zoom:1;}
.fix:after,.fix:before{display:block;content:"clear";height:0;clear:both;overflow:hidden;visibility:hidden;}
.z{_zoom:1;}
.h1{height:1px;}
.h5{height:5px;}
.h10,.h{height:10px;}
.h15{height:15px;}
.h20{height:20px;}
.h1,.h5,.h10,.h15,.h20,.h{font-size:0px;line-height:0;overflow:hidden;clear:both;}
body{font:12px 宋体,Arial,sans-serif;}
a{text-decoration:none;}
a:hover{color:#FF6600}
p{line-height:1.5;}
附件:下载该文件资源,减少时间成本(增值服务)
留言
该资源可下载
File Source
.rar
34.82 KB
jquery特效6
最新结算
jquery虚拟键盘中文打字效果js代码
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
jquery虚拟键盘中文打字效果js代码
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
HTML5实现CSS滤镜图片切换特效代码
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
jQuery头像裁剪插件cropbox js代码
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
jQuery头像裁剪插件cropbox js代码
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
CSS3制作3D图片立方体旋转特效
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
CSS3制作3D图片立方体旋转特效
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
CSS3制作3D图片立方体旋转特效
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
CSS3制作3D图片立方体旋转特效
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
jQuery+css3实现信封效果
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
我们力求给您提供有用的文章,再此基础上,会附加营收资源,不做任何广告,让平台可以更好发展 若您发现您的权利被侵害,或使用了您的版权,请发邮件联系 sunlifel@foxmail.com ggbig觉得 : 不提供源码的文章不是好文章
合作伙伴
联系我们
  • QQ:21499807
  • 邮箱:sunlifel@foxmail.com
  • QQ扫一扫加QQ
    QQ扫一扫
Copyright 2023-2024 ggbig.com·皖ICP备2023004211号-1
打赏文章