此代码适用于FF和IE但不适用于Chrome。任何帮助将不胜感激。 谢谢!意识到此代码本身可以正常工作,但是当它在此页面上托管(http://www.automotive-fleet.com)时,它在Chrome和Safari中无效。我无法弄清楚为什么。任何帮助,将不胜感激。
这是html
<div id="popularsearches">
<div id="popularsearches-inside">
<div id="popularsearches-left">
<ul>
<li>Item One </li>
<li>Item Two </li>
<li>Item Three </li>
<li>Item Four </li>
<li>Item Five</a> </li>
</ul>
</div>
<div id="popularsearches-right">
<ul>
<li>Item Six </li>
<li>Item Seven </li>
<li>Item Eight </li>
<li>Item Nine </li>
<li>Item ten </li>
</ul>
</div>
</div>
</div>
这是css
#popularsearches
{
border-bottom: 1px solid #D4D4D4;
border-left: 1px solid #D4D4D4;
border-right: 1px solid #D4D4D4;
overflow:hidden;
height: 130px; width:248px;
margin-bottom:20px;
}
#popularsearches ul
{
padding:0 5px 0 0;
margin:0;
}
#popularsearches ul li
{
list-style-type:none;
list-style-position:inside;
border-bottom: solid 1px #D4D4D4;
font-size:14px;
padding:3px 0 3px 0;
margin:0 0 0 10px;
text-align:left;
}
#popularsearches ul li a
{
text-decoration:none;
}
#popularsearches ul li a:hover, a:link, a:visited
{
text-decoration:none;
}
#popularsearches-inside
{
width: 500px;
}
#popularsearches-left
{
float:left;
width:250px;
height:100px;
}
#popularsearches-right
{
float:left;
width:250px;
height:100px;
}
这里是jQuery
var closeinterval = 0;
function scrollContent() {
//Toggle left between 250 and 0
var top = jQuery("#popularsearches").scrollLeft() == 0 ? 250 : 0;
jQuery("#popularsearches").animate({ scrollLeft: top }, "slow");
}
// Call scrollContent function every 6 secs
closeinterval = setInterval("scrollContent()", 6000);
jQuery(document).ready(function() {
jQuery("#popular-button-left").bind("click", function() {
if (closeinterval) {
window.clearInterval(closeinterval);
closeinterval = null;
}
jQuery("#popularsearches").animate({ scrollLeft: 0 }, 1000);
});
jQuery("#popular-button-right").bind("click", function() {
if (closeinterval) {
window.clearInterval(closeinterval)
closeinterval = null;
}
jQuery("#popularsearches").animate({ scrollLeft: 250 }, 1000);
});
});
答案 0 :(得分:4)
更改此行:
closeinterval = setInterval("scrollContent()", 6000);
对此:
closeinterval = setInterval(scrollContent, 6000);
这为我解决了..请参阅示例here
答案 1 :(得分:1)
可能是以下div中的iffy标记吗?
<div id="popularsearches-left">
<ul>
<li>Item One </li>
<li>Item Two </li>
<li>Item Three </li>
<li>Item Four </li>
<li>Item Five</a> <-- renegade closing tag</li>
</ul>
</div>