菜单_淘宝首页的拼音排序效果

1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-loose.dtd">2
<html xmlns="http://www.w3.org/1999/xhtml">3
<head>4
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />5
<title>仿taobao效果 -- 小秦修改版</title>6
<style type="text/css">7

*{
}{ margin:0;padding:0;}8

body{
}{ font:normal 12px Verdana, Arial, Helvetica, sans-serif; text-align:center;}9

#warpper{
}{ position:absolute; left:100px; top:100px;}10

h5{
}{ float:left;}11

a{
}{ text-decoration:underline; cursor:pointer; font-weight:bold;}12

dl{
}{ height:18px; line-height:18px; background:#f7f7f7; padding:0 10px;}13

dt,.normal{
}{ float:left; padding:0 10px; border-right:1px solid #ccc; text-decoration:none; width:auto; cursor:pointer;}14

dt.over{
}{ position:relative;border:1px solid #86e5f0; padding:0 10px 15px 10px; border-bottom:1px solid #caf1f1; margin:-1px 0 0 -1px; z-index:1000; color:#ff6026; text-decoration:underline; background:#caf1f1; height:22px; }15

li{
}{ float:left; list-style-type:none; margin:5px 10px; width:120px;}16

dl dd{
}{ position:absolute; width:500px; left:0;top:37px!important; border:1px solid #86e5f0; background:#caf1f1; filter:progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=120, color=#cccccc); padding:10px 0;}17

.block{
}{ display:block;}18

.none{
}{ display:none;}19
</style>20
<script language="javascript">21

function XMenu(o){
}{22
this.$ = function(o){ return document.getElementById(o);}23

this.$$ = function(o, str){
}{ return o.getElementsByTagName(str);}24
this.obj = o;25
this.bind();26
}27

XMenu.prototype = {
}{28
bind : function(){29
var xxx = this.$(this.obj); //得到传对的对象。在这里,我没有做容错处理。没有判断这个对象存在不存在,如果需要请自己判断。30
var xdt = this.$$(xxx, 'dt');//得到这个对象下的所有的dt31
var xdd = this.$$(xxx, 'dd');//得到这个对象下的所有的dd32
var xdtl = xdt.length;//取得有几个dt33
xxx['obj'] = xdt[0];//给传的对象添加一个属性obj,值为 第一个 dd34
for(var i=0; i<xdtl; i++){//循环 该对象下的所有的 dd,并为它添加onmouseover事件。35
xdt[i]['dd'] = xdd[i];//给当前对象添加一个属性dd,值为,与它相对应的dd对象,它的作用是在移动到当前对象的时候给与它相对应的dd设置样式用的。36
xdt[i]['div'] = xxx;//给当前对象添加一个属性div,值为,调用XMenu时,所传入的参数所对应的对象。37
xdt[i].onmouseover = function(){38
this['div']['obj'].className = 'normal';39
this['div']['obj']['dd'].className = 'none';40
this.className = 'over';41
this['dd'].className = 'block';42
this['div']['obj'] = this;43
}44
}45

xxx.onmouseout = function(){
}{46
var d = this;//用来保存当前的xxx对象47
this.hide = setTimeout(function(){48
d['obj'].className = 'normal';49
d['obj']['dd'].className = 'none';50
d = null;51
},2000); //鼠标移出后几秒隐藏。在这里设置时间[秒数*1000]52
}53

xxx.onmouseover = function(){
}{54
if(this.hide){55
clearTimeout(this.hide);56
}57
}58
}59
}60

window.onload = function (){
}{//在文档onload事件绑定事件处理函数。61
new XMenu('warpper'); //传入id。该对象下的所有dt将会被绑定onmouseover事件。62
}63
</script>64
</head>65
<body>66
<dl id="warpper">67
<h5>拼音检索:</h5>68
<dt>a</dt>69
<dd class="none">70
<ul>71
<li><a herf="#">Adidas</a></li>72
<li><a herf="#">AEE/爱意</a></li>73
<li><a herf="#">AF</a></li>74
<li><a herf="#">AF棒球帽</a></li>75
<li><a herf="#">Agatha</a></li>76
</ul>77
</dd>78
<dt>b</dt>79
<dd class="none">80
<ul>81
<li><a herf="#">fasfs</a></li>82
<li><a herf="#">fsdfsd</a></li>83
</ul>84
</dd>85
<dt>c[ch]</dt>86
<dd class="none">87
<ul>88
<li><a herf="#">fasfs</a></li>89
<li><a herf="#">fsdfsd</a></li>90
<li><a herf="#">fdsfas</a></li>91
</ul>92
</dd>93
<dt>d</dt>94
<dd class="none">95
<ul>96
<li><a herf="#">fasfs</a></li>97
<li><a herf="#">fsdfsd</a></li>98
<li><a herf="#">fdsfas</a></li>99
<li><a herf="#">fasdffsd</a></li>100
</ul>101
</dd>102
<dt>e</dt>103
<dd class="none">104
<ul>105
<li><a herf="#">fasfs</a></li>106
<li><a herf="#">fsdfsd</a></li>107
<li><a herf="#">fdsfas</a></li>108
<li><a herf="#">fasdffsd</a></li>109
<li><a herf="#">fasdfsaf</a></li>110
</ul>111
</dd>112
<dt>f</dt>113
<dd class="none">114
<ul>115
<li><a herf="#">Fancl</a></li>116
<li><a herf="#">Fancl</a></li>117
<li><a herf="#">Fancl</a></li>118
<li><a herf="#">Fancl</a></li>119
<li><a herf="#">Fancl</a></li>120
<li><a herf="#">Fancl</a></li>121
</ul>122
</dd>123
</dl>124
</body>125
</html>

浙公网安备 33010602011771号