日期:2014-05-16 浏览次数:20454 次
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>淘宝首页图片轮播效果</title>
<style>
<!--
* {margin: 0;padding:0;}
body {background: #222;}
ol {list-style: none;}
img {border: 0 none;}
#slider {
border: 1px solid #F60;
width: 490px;
height: 170px;
overflow: hidden;
position: relative;
margin: 2em auto;
}
#slider .player {
/*width: 2450px;
height: 850px;*/
position: absolute;
top: 0px;
left: 0px;
}
#slider .player li {
width: 490px;
height: 170px;
}
#slider .btns {
position: absolute;
right: 10px;
bottom: 5px;
height: 30px;
}
#slider .btns li {
font: 13px Tahoma, Arial, 宋体, sans-serif;
float: left;
margin: 0 3px;
border: 1px solid #F60;
background-color: #FFF;
color: #CC937A;
opacity: .8;
cursor: pointer;
width: 20px;
height: 20px;
line-height: 19px;
text-align: center;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
}
#slider .btns li.active {
background: #F60;
color: #FFF;
font-weight: bold;
opacity: 1;
}
-->
</style>
<script>
//<![CDATA[
function $(id) {
return document.getElementById(id);
};
function getByClass(className, context) {
/*
* 功能说明:
* 传入类名、节点名(默认document),获取context下类名为classNa的节点
*/
context = context
------解决方案--------------------
document;
if(context.getElementsByClassName) {
return context.getElementsByClassName(className);
} else {
var nodes = [];
var tags = context.getElementsByTagName('*');
for(var i=0, len=tags.length; i<len; i++) {
if(hasClass(tags[i], className)) {
nodes.push(tags[i]);
}
}
return nodes;
}
}
function hasClass(node, className) {
/*
* 功能说明:
* 传入节点及一个类名,检查该节点是否含有传入的类名
*/
var names = node.className.split(/\s+/);
for(var i=0, len=names.length; i<len; i++) {
if(names