js,怎么给banner大图轮播加触摸事件? 50
虽然明白原理;但是不知道具体怎么写;麻烦大神帮忙下<!doctypehtml><html><head><metacharset="utf-8"><title>banner...
虽然明白原理;但是不知道具体怎么写;麻烦大神帮忙下
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>banner</title>
<link rel="stylesheet" type="text/css" href="css/1.css" />
</head>
<body>
<!--图片轮播-->
<div class="rq" id="imgs" onmouseover="over()"onmouseout="out()">
<a href="#" title="图1文字描述">
<div class="fl rq abs tra bn1">1</div>
</a>
<a href="#" title="图2文字描述">
<div class="fl rq abs tra bn2">2</div>
</a>
<a href="#" title="图3文字描述">
<div class="fl rq abs tra bn3">3</div>
</a>
</div>
<!--切换按钮-->
<div class="an" onmouseover="over()"onmouseout="out()" id="ans">
<div onmouseover="hover_(this)" class="fl tra mu">
<div></div>
</div>
<div onmouseover="hover_(this)" class="fl tra mu">
<div></div>
</div>
<div onmouseover="hover_(this)" class="fl tra mu">
<div></div>
</div>
</div>
</body>
</html>
for (var i = 0; i < imgs.length; i++) {
var temp = i - curr;
imgs[i].style.left = temp * 100 + "%";
ans[i].getElementsByTagName("div")[0].style.backgroundColor = (temp == 0?'#FFF':'#555'); }
curr++;
if (curr == imgs.length) {
curr = 0; }}
function hover_(obj){
var ans = getElementNoBlank("ans");
for (var i = 0; i < ans.length; i++) {
if(ans[i] === obj){
curr = i;
interval(); } };} 展开
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>banner</title>
<link rel="stylesheet" type="text/css" href="css/1.css" />
</head>
<body>
<!--图片轮播-->
<div class="rq" id="imgs" onmouseover="over()"onmouseout="out()">
<a href="#" title="图1文字描述">
<div class="fl rq abs tra bn1">1</div>
</a>
<a href="#" title="图2文字描述">
<div class="fl rq abs tra bn2">2</div>
</a>
<a href="#" title="图3文字描述">
<div class="fl rq abs tra bn3">3</div>
</a>
</div>
<!--切换按钮-->
<div class="an" onmouseover="over()"onmouseout="out()" id="ans">
<div onmouseover="hover_(this)" class="fl tra mu">
<div></div>
</div>
<div onmouseover="hover_(this)" class="fl tra mu">
<div></div>
</div>
<div onmouseover="hover_(this)" class="fl tra mu">
<div></div>
</div>
</div>
</body>
</html>
for (var i = 0; i < imgs.length; i++) {
var temp = i - curr;
imgs[i].style.left = temp * 100 + "%";
ans[i].getElementsByTagName("div")[0].style.backgroundColor = (temp == 0?'#FFF':'#555'); }
curr++;
if (curr == imgs.length) {
curr = 0; }}
function hover_(obj){
var ans = getElementNoBlank("ans");
for (var i = 0; i < ans.length; i++) {
if(ans[i] === obj){
curr = i;
interval(); } };} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询