Jquery悬停和切换功能在IE6中不起作用?
这个自定义滑块在所有其他浏览器中工作正常,但 IE6/可能 7 像往常一样令人痛苦。尽管我很想使用预制滑块,但这不是一个选择。
这是主要代码:
$(document).ready(function() {
//Slider Movement
//Slide 1
$(".hpsnav1").click(function() {
$(".slider-list").animate(
{
marginLeft: "-40px",
}, 1000 );
});
//Slide 2
$(".hpsnav2").click(function() {
$(".slider-list").animate(
{
marginLeft: "-744px",
}, 1000 );
});
//Slide 3
$(".hpsnav3").click(function() {
$(".slider-list").animate(
{
marginLeft: "-1448px",
}, 1000 );
});
//Slide 4
$(".hpsnav4").click(function() {
$(".slider-list").animate(
{
marginLeft: "-2152px",
}, 1000 );
});
//Slide 5
$(".hpsnav5").click(function() {
$(".slider-list").animate(
{
marginLeft: "-2860px",
}, 1000 );
});
// Slide Previews
$(".hpsnav1").live('hover', function() {
$(".prvw1").toggle();
})
$(".hpsnav2").live('hover', function() {
$(".prvw2").toggle();
})
$(".hpsnav3").live('hover', function() {
$(".prvw3").toggle();
})
$(".hpsnav4").live('hover', function() {
$(".prvw4").toggle();
})
$(".hpsnav5").live('hover', function() {
$(".prvw5").toggle();
})
});
这是 HTML:
<div class="slider-wrap">
<div class="slider-nav">
<ul class="slider-nav-options">
<li class="hpsnav1">1</li>
<li class="hpsnav2">2</li>
<li class="hpsnav3">3</li>
<li class="hpsnav4">4</li>
<li class="hpsnav5">5</li>
</ul>
<div class="slider-preview prvw1">Preview 1</div>
<div class="slider-preview prvw2">Preview 2</div>
<div class="slider-preview prvw3">Preview 3</div>
<div class="slider-preview prvw4">Preview 4</div>
<div class="slider-preview prvw5">Preview 5</div>
</div>
<ul class="slider-list">
<li style="background:#066;" class="firstslide hps1"></li>
<li style="background:#960;" class="hps2"></li>
<li style="background:#3CC;" class="hps3"></li>
<li style="background:#639;" class="hps4"></li>
<li style="background:#9FF;" class="hps5"></li>
</ul>
</div>
这是主要样式表:
.slider-wrap {
margin:0;
width:704px;
height:313px;
overflow:hidden;
background:#F00;
}
.slider-list {
margin:-67px 0 0 -40px;
width:4000px;
height:271px;
list-style:none;
background:#06F;
}
.slider-list .firstslide {
margin-left:0;
}
.slider-list li {
margin:0 0 0 -8px;
width:708px;
height:271px;
position:relative;
display:inline-block;
top:0px;
}
.hps1 {background:#0F0;}
.hps2 {background:#093;}
.hps3 {background:#0CC;}
.hps4 {background:#66C;}
.hps5 {background:#F63;}
.slider-nav {
margin:0;
width:704px;
height:47px;
background:#f8d824;
position:relative;
top:250px;
}
.slider-nav-options li {
display:inline;
cursor:pointer;
position:relative;
top:13px;
}
.slider-preview {
width:460px;
height:20px;
position:relative;
left:220px;
top:-24px;
display:none;
text-align:center;
}
这是 IE6 样式表:
@charset "utf-8";
/* New Slider - IE6 */
.slider-wrap {
position:relative;
margin:0;
width:704px;
height:313px;
background:#F00;
overflow:hidden;
}
.slider-list {
margin:-47px 0 0 -4px;
width:4000px;
height:271px;
list-style:none;
background:#06F;
overflow:hidden;
}
.slider-list .firstslide {
margin-left:2px!important;
}
.slider-list li {
margin:0 0 0 -8px;
float:left;
width:712px;
height:266px;
position:relative;
display:inline-block;
top:0px;
}
.hps1 {background:#0F0;}
.hps2 {background:#093;}
.hps3 {background:#0CC;}
.hps4 {background:#66C;}
.hps5 {background:#F63;}
.slider-nav {
margin:0;
width:704px;
height:47px;
background:#f8d824;
position:relative;
top:266px;
}
.slider-nav-options li {
display:inline;
cursor:pointer;
position:relative;
top:13px;
}
.slider-preview {
width:460px;
height:20px;
position:relative;
left:220px;
top:-24px;
display:none;
text-align:center;
}
This custom slider works fine in all the other browsers, but IE6/possibly 7 are being a pain as usual. As much as I'd like to use a premade slider, it is not an option.
Here's the main code:
$(document).ready(function() {
//Slider Movement
//Slide 1
$(".hpsnav1").click(function() {
$(".slider-list").animate(
{
marginLeft: "-40px",
}, 1000 );
});
//Slide 2
$(".hpsnav2").click(function() {
$(".slider-list").animate(
{
marginLeft: "-744px",
}, 1000 );
});
//Slide 3
$(".hpsnav3").click(function() {
$(".slider-list").animate(
{
marginLeft: "-1448px",
}, 1000 );
});
//Slide 4
$(".hpsnav4").click(function() {
$(".slider-list").animate(
{
marginLeft: "-2152px",
}, 1000 );
});
//Slide 5
$(".hpsnav5").click(function() {
$(".slider-list").animate(
{
marginLeft: "-2860px",
}, 1000 );
});
// Slide Previews
$(".hpsnav1").live('hover', function() {
$(".prvw1").toggle();
})
$(".hpsnav2").live('hover', function() {
$(".prvw2").toggle();
})
$(".hpsnav3").live('hover', function() {
$(".prvw3").toggle();
})
$(".hpsnav4").live('hover', function() {
$(".prvw4").toggle();
})
$(".hpsnav5").live('hover', function() {
$(".prvw5").toggle();
})
});
Here is the HTML:
<div class="slider-wrap">
<div class="slider-nav">
<ul class="slider-nav-options">
<li class="hpsnav1">1</li>
<li class="hpsnav2">2</li>
<li class="hpsnav3">3</li>
<li class="hpsnav4">4</li>
<li class="hpsnav5">5</li>
</ul>
<div class="slider-preview prvw1">Preview 1</div>
<div class="slider-preview prvw2">Preview 2</div>
<div class="slider-preview prvw3">Preview 3</div>
<div class="slider-preview prvw4">Preview 4</div>
<div class="slider-preview prvw5">Preview 5</div>
</div>
<ul class="slider-list">
<li style="background:#066;" class="firstslide hps1"></li>
<li style="background:#960;" class="hps2"></li>
<li style="background:#3CC;" class="hps3"></li>
<li style="background:#639;" class="hps4"></li>
<li style="background:#9FF;" class="hps5"></li>
</ul>
</div>
Here's the main stylesheet:
.slider-wrap {
margin:0;
width:704px;
height:313px;
overflow:hidden;
background:#F00;
}
.slider-list {
margin:-67px 0 0 -40px;
width:4000px;
height:271px;
list-style:none;
background:#06F;
}
.slider-list .firstslide {
margin-left:0;
}
.slider-list li {
margin:0 0 0 -8px;
width:708px;
height:271px;
position:relative;
display:inline-block;
top:0px;
}
.hps1 {background:#0F0;}
.hps2 {background:#093;}
.hps3 {background:#0CC;}
.hps4 {background:#66C;}
.hps5 {background:#F63;}
.slider-nav {
margin:0;
width:704px;
height:47px;
background:#f8d824;
position:relative;
top:250px;
}
.slider-nav-options li {
display:inline;
cursor:pointer;
position:relative;
top:13px;
}
.slider-preview {
width:460px;
height:20px;
position:relative;
left:220px;
top:-24px;
display:none;
text-align:center;
}
Here's the IE6 stylesheet:
@charset "utf-8";
/* New Slider - IE6 */
.slider-wrap {
position:relative;
margin:0;
width:704px;
height:313px;
background:#F00;
overflow:hidden;
}
.slider-list {
margin:-47px 0 0 -4px;
width:4000px;
height:271px;
list-style:none;
background:#06F;
overflow:hidden;
}
.slider-list .firstslide {
margin-left:2px!important;
}
.slider-list li {
margin:0 0 0 -8px;
float:left;
width:712px;
height:266px;
position:relative;
display:inline-block;
top:0px;
}
.hps1 {background:#0F0;}
.hps2 {background:#093;}
.hps3 {background:#0CC;}
.hps4 {background:#66C;}
.hps5 {background:#F63;}
.slider-nav {
margin:0;
width:704px;
height:47px;
background:#f8d824;
position:relative;
top:266px;
}
.slider-nav-options li {
display:inline;
cursor:pointer;
position:relative;
top:13px;
}
.slider-preview {
width:460px;
height:20px;
position:relative;
left:220px;
top:-24px;
display:none;
text-align:center;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你应该使用这个:
但是,如果您确实找不到答案,您可以说该网站与 IE 不兼容。
You should use this:
However, if you actually don't find an answer, you can just say this website isn't compatible with IE.