虽然很长,但如果大家有空就看下,刷新页面的时候,文字图片都在,但是点了左移,右移动,第二第三个产品的文字就不见了我想是复制的时候出错,但是我不太会改
我觉得是这里出错↓
var e=$(this).clone();
e.attr("p", 'sl_'+nn);
nn++;
<div id="slider">
<div id="slot_left" class="slot">
<ul></ul>
<div class="desc2"></div>
</div>
<div id="slot_center" class="slot">
<ul></ul>
<div class="desc"></div>
</div>
<div id="slot_right" class="slot">
<ul></ul>
<div class="desc2"></div>
</div>
<a href="#" class="do_slide left"></a>
<a href="#" class="do_slide right"></a>
<ul id="slides">
<%for i=1 to 5 %>
<li>
<a class="pipi" href="index.asp"><img src="images/1.jpg" width="205" height="377" /><div><p >dd123dd</p></div></a>
</li>
<li>
<a class="pipi" href="index.asp"><img src="images/2.jpg" width="205" height="377" /><div><p >d43dd</p></div></a>
</li>
<li>
<a class="pipi" href="index.asp"><img src="images/3.jpg" width="205" height="377" /><div><p >21</p></div> </a>
</li>
<%next%>
</ul>JS
$(document).ready(function() { if (!$(".slot").length) return; // 320x190
// 260x155
//return;
var sl_speed=0;
var sl_speed=0;
var sl_speed=slider_settings.speed;
var sl_timeout=0;
var sl_speed_fout=0;
var first_run=true; var n = 1;
$(".slot ul").each(function () {
$(this).attr("id", "k"+(n++)).addClass('cycle');//加载cycle.js
}); /*
n = 1;
$(".slot").each(function () {
$(this).attr("id", "s"+(n++));
});
*/ $("#k1, #k2, #k3").each(function () {
$(this).html("");
});
var nn = 1;
$("#slides").children().each(function () {
$(this).attr("id", "for_sl_"+nn);
var e=$(this).clone();
e.attr("p", 'sl_'+nn);
nn++;
e.find("img").attr("width", 205);/*中间图片大小*/
e.find("img").attr("height", 377);/*中间图片大小*/
$("#k2").append(e.clone());
e.find("img").attr("width", 160);/*侧面图大小*/
e.find("img").attr("height", 294);/*侧面图大小*/
e.find("img").attr("src", e.find("img").attr("src").replace('205x377', '160x294'));
$("#k1").append(e);
$("#k3").append(e.clone());
}); $("#k1, #k2, #k3").each(function () {
var n=parseInt($(this).attr('id').substring(1));
var e=$("#k"+n).children();
$(e[n-1]).css({
'z-index': '999',
'position': 'absolute',
'left': 0
});
});
//alert("?");
//return;
/*大小图样式*/
$(".slot .desc").each(function () {
$(this).css({
opacity: 'none',
visibility: 'visible',
width:140,
height:30,
align:'center',
left:-30,
top:370,
display:'block'
});
$(".slot .desc2").each(function () {
$(this).css({
opacity: 'none',
visibility: 'visible',
width:140,
height:30,
align:'center',
left:-10,
top:370,
display:'block'
});
$(this).hover(function () {
if ($.browser.msie)
{
$(this).css('opacity', 'none');
this.style.removeAttribute('filter');
return;
}
$(this).animate({
opacity: 'none',
display:'block'
}, {
duration: 300,
queue: false,
complete: function () {
if ($.browser.msie) this.style.removeAttribute('filter');
}
});
}, function () {
if ($.browser.msie)
{
$(this).css('opacity', 'none'); return;
}
$(this).animate({
opacity: 'none',
display:'block'
}, {
duration: 300,
queue: false,
complete: function () {
//if ($.browser.msie) this.style.removeAttribute('filter');
}
});
});
});
//return;
//return;
/*
alert($("#k1").html());
alert($("#k2").html());
alert($("#k3").html());
*/ //return; if ($("#slides").children().length == 1)
{
return;
} //return;
var f_run = 0; $(".cycle").each(function () {
var n=parseInt($(this).attr('id').substring(1));
//alert(n);
var st=0;
if (n==2) st=0;
if (n==3) st=$(this).find("a").length-1;
if (n==1) st=1;
//st++;
var o={
w: 320,/*中间图速度*/
startZindex: 10,
fx: 'scrollHorz',
speed: sl_speed,
timeout: 0,
startingSlide: st,
//easing: 'easeOutExpo',
easing: slider_settings.easing,
selector: '',
oneAfterAnother: slider_settings.oneAfterAnother,
//continuous: true,
fit: false,
pager: '#slider_dots',
next: ".right",
prev: ".left",
cssAfter: {
left: 0
},
after: function (currSlideElement, nextSlideElement, options) {
var a=$(nextSlideElement);
var b=$(currSlideElement);
a.css({left: 0});
b.css({left: 0});
},
before: function (currSlideElement, nextSlideElement, options, forwardFlag) {
if (options.nextSlide==options.currSlide && $("#slides").children().length!=1) return;
var ee = "slot_";
if (o.second) ee+="center";
else if (o.third) ee+="right";
else ee += "left";
//;
var hh = $("#for_" + $(nextSlideElement).attr("id")).find("a").html();
var hhh = $("#for_" + $(nextSlideElement).attr("id")).find("a").attr("href");
var hht = $("#for_" + $(nextSlideElement).attr("id")).find("p").text();
//alert(hh);
f_run++;
if (f_run == 4) return;//文字
//alert(ee+": "+hht);
$("#"+ee).children(".desc").attr( "href", hhh );
$("#"+ee).children(".desc").html( hh );
$("#"+ee).children(".desc").find("p").html( hht );
$("#"+ee).children(".desc2").attr( "href", hhh );
$("#"+ee).children(".desc2").html( hh );
$("#"+ee).children(".desc2").find("p").html( hht );
if (is_day)
{
Cufon('.desc h4', {
color: '-linear-gradient(#fff, 0.4=#e8eaeb, #b0b5b8)'
});
}
else
{
Cufon('.desc h4', {
color: '-linear-gradient(#282828, #1d1d1d)'
});
}
}
};
if (n==2) o.second=1;
if (n==3) o.third=1;
$(this).cycle(o);
});
$(".cycle:eq(0)").cycle('pager');
$(".desc").click(function () {
window.location.href = $(this).attr("href");
return false;
});
$(".desc2").click(function () {
window.location.href = $(this).attr("href");
return false;
});});
});
我觉得是这里出错↓
var e=$(this).clone();
e.attr("p", 'sl_'+nn);
nn++;
<div id="slider">
<div id="slot_left" class="slot">
<ul></ul>
<div class="desc2"></div>
</div>
<div id="slot_center" class="slot">
<ul></ul>
<div class="desc"></div>
</div>
<div id="slot_right" class="slot">
<ul></ul>
<div class="desc2"></div>
</div>
<a href="#" class="do_slide left"></a>
<a href="#" class="do_slide right"></a>
<ul id="slides">
<%for i=1 to 5 %>
<li>
<a class="pipi" href="index.asp"><img src="images/1.jpg" width="205" height="377" /><div><p >dd123dd</p></div></a>
</li>
<li>
<a class="pipi" href="index.asp"><img src="images/2.jpg" width="205" height="377" /><div><p >d43dd</p></div></a>
</li>
<li>
<a class="pipi" href="index.asp"><img src="images/3.jpg" width="205" height="377" /><div><p >21</p></div> </a>
</li>
<%next%>
</ul>JS
$(document).ready(function() { if (!$(".slot").length) return; // 320x190
// 260x155
//return;
var sl_speed=0;
var sl_speed=0;
var sl_speed=slider_settings.speed;
var sl_timeout=0;
var sl_speed_fout=0;
var first_run=true; var n = 1;
$(".slot ul").each(function () {
$(this).attr("id", "k"+(n++)).addClass('cycle');//加载cycle.js
}); /*
n = 1;
$(".slot").each(function () {
$(this).attr("id", "s"+(n++));
});
*/ $("#k1, #k2, #k3").each(function () {
$(this).html("");
});
var nn = 1;
$("#slides").children().each(function () {
$(this).attr("id", "for_sl_"+nn);
var e=$(this).clone();
e.attr("p", 'sl_'+nn);
nn++;
e.find("img").attr("width", 205);/*中间图片大小*/
e.find("img").attr("height", 377);/*中间图片大小*/
$("#k2").append(e.clone());
e.find("img").attr("width", 160);/*侧面图大小*/
e.find("img").attr("height", 294);/*侧面图大小*/
e.find("img").attr("src", e.find("img").attr("src").replace('205x377', '160x294'));
$("#k1").append(e);
$("#k3").append(e.clone());
}); $("#k1, #k2, #k3").each(function () {
var n=parseInt($(this).attr('id').substring(1));
var e=$("#k"+n).children();
$(e[n-1]).css({
'z-index': '999',
'position': 'absolute',
'left': 0
});
});
//alert("?");
//return;
/*大小图样式*/
$(".slot .desc").each(function () {
$(this).css({
opacity: 'none',
visibility: 'visible',
width:140,
height:30,
align:'center',
left:-30,
top:370,
display:'block'
});
$(".slot .desc2").each(function () {
$(this).css({
opacity: 'none',
visibility: 'visible',
width:140,
height:30,
align:'center',
left:-10,
top:370,
display:'block'
});
$(this).hover(function () {
if ($.browser.msie)
{
$(this).css('opacity', 'none');
this.style.removeAttribute('filter');
return;
}
$(this).animate({
opacity: 'none',
display:'block'
}, {
duration: 300,
queue: false,
complete: function () {
if ($.browser.msie) this.style.removeAttribute('filter');
}
});
}, function () {
if ($.browser.msie)
{
$(this).css('opacity', 'none'); return;
}
$(this).animate({
opacity: 'none',
display:'block'
}, {
duration: 300,
queue: false,
complete: function () {
//if ($.browser.msie) this.style.removeAttribute('filter');
}
});
});
});
//return;
//return;
/*
alert($("#k1").html());
alert($("#k2").html());
alert($("#k3").html());
*/ //return; if ($("#slides").children().length == 1)
{
return;
} //return;
var f_run = 0; $(".cycle").each(function () {
var n=parseInt($(this).attr('id').substring(1));
//alert(n);
var st=0;
if (n==2) st=0;
if (n==3) st=$(this).find("a").length-1;
if (n==1) st=1;
//st++;
var o={
w: 320,/*中间图速度*/
startZindex: 10,
fx: 'scrollHorz',
speed: sl_speed,
timeout: 0,
startingSlide: st,
//easing: 'easeOutExpo',
easing: slider_settings.easing,
selector: '',
oneAfterAnother: slider_settings.oneAfterAnother,
//continuous: true,
fit: false,
pager: '#slider_dots',
next: ".right",
prev: ".left",
cssAfter: {
left: 0
},
after: function (currSlideElement, nextSlideElement, options) {
var a=$(nextSlideElement);
var b=$(currSlideElement);
a.css({left: 0});
b.css({left: 0});
},
before: function (currSlideElement, nextSlideElement, options, forwardFlag) {
if (options.nextSlide==options.currSlide && $("#slides").children().length!=1) return;
var ee = "slot_";
if (o.second) ee+="center";
else if (o.third) ee+="right";
else ee += "left";
//;
var hh = $("#for_" + $(nextSlideElement).attr("id")).find("a").html();
var hhh = $("#for_" + $(nextSlideElement).attr("id")).find("a").attr("href");
var hht = $("#for_" + $(nextSlideElement).attr("id")).find("p").text();
//alert(hh);
f_run++;
if (f_run == 4) return;//文字
//alert(ee+": "+hht);
$("#"+ee).children(".desc").attr( "href", hhh );
$("#"+ee).children(".desc").html( hh );
$("#"+ee).children(".desc").find("p").html( hht );
$("#"+ee).children(".desc2").attr( "href", hhh );
$("#"+ee).children(".desc2").html( hh );
$("#"+ee).children(".desc2").find("p").html( hht );
if (is_day)
{
Cufon('.desc h4', {
color: '-linear-gradient(#fff, 0.4=#e8eaeb, #b0b5b8)'
});
}
else
{
Cufon('.desc h4', {
color: '-linear-gradient(#282828, #1d1d1d)'
});
}
}
};
if (n==2) o.second=1;
if (n==3) o.third=1;
$(this).cycle(o);
});
$(".cycle:eq(0)").cycle('pager');
$(".desc").click(function () {
window.location.href = $(this).attr("href");
return false;
});
$(".desc2").click(function () {
window.location.href = $(this).attr("href");
return false;
});});
});
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货