话说,你连定位一下问题哪里出错,都不定位,这就让人去整理这400行的代码,去复现你的问题吗?

解决方案 »

  1.   


    我的意思是 我做个选项卡 当选项卡切换到滚动2的时候 滚动2里面的那个焦点图效果不能实现 可是我两个焦点图 单独拿出来的时候是可以实现的
      

  2.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>图片滚动</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script type="text/javascript">
    $(function(){
    var $div_li = $("div.div_head ul li");
    $div_li.click(function(){
    var index =  $div_li.index(this); 
    var cl = index || ''; 
    $(this).addClass("active").siblings().removeClass("active"); 
    $("div.content > div").eq(index).show().siblings().hide();
    bindScroll("picBox" + cl, "listBox" + cl, "prev" + cl, "next" + cl, "prevTop" + cl, "nextTop" + cl);
    }).hover(function(){
    $(this).addClass("hover");
    },function(){
    $(this).removeClass("hover");
    });

    bindScroll("picBox","listBox","prev","next","prevTop","nextTop");

    function bindScroll() {
    var box = $('#' + arguments[0]);
    var is = box.attr('init');
    if(is !== 'true') {
    box.attr('init', 'true');
    huadong.apply(window, arguments);
    }
    }
    });
    </script>
    </head>
    <body>
    <style type="text/css">
    * {
    margin: 0;
    padding: 0;
    list-style-type: none
    }a,img {
    border: 0
    }body {
    font: 12px/180% Arial,Helvetica,sans-serif,"新宋体"
    }.div {
    width: 599px;
    float: left
    }.div_head {
    width: 599px;
    height: 35px;
    float: left
    }.div_head li {
    width: 120px;
    height: 30px;
    float: left;
    cursor: pointer
    }.div_head .active {
    background: #00bcf3;
    color: #FFF
    }.mod18 {
    width: 599px;
    position: relative;
    background: #f7f7f7
    }.mod18 .btn {
    position: absolute;
    width: 15px;
    height: 70px;
    bottom: 0;
    cursor: pointer;
    z-index: 99;
    font-size: 50px;
    font-weight: bold
    }.mod18 .prev {
    left: 0;
    background: url(images/prevBtn.png) no-repeat
    }.mod18 #prevTop,.mod18 #nextTop,.mod18 #prevTop1,.mod18 #nextTop1 {
    top: 213px;
    width: 46px;
    height: 48px
    }.mod18 #prevTop,.mod18 #prevTop1 {
    background: url(images/prevBtnTop.png) 0 0 no-repeat
    }.mod18 #nextTop,.mod18 #nextTop1 {
    background: url(images/nextBtnTop.png) 0 0 no-repeat
    }.mod18 .next {
    right: 0;
    background: url(images/nextBtn.png) no-repeat
    }.mod18 li {
    float: left
    }.mod18 .cf li {
    position: relative;
    color: #fff
    }.mod18 .cf a {
    display: block;
    width: 599px;
    height: 415px;
    position: absolute;
    color: #fff
    }.mod18 .cf li span {
    display: block;
    width: 599px;
    position: absolute;
    left: 0;
    bottom: 0;
    padding: 10px 20px;
    line-height: 22px;
    text-align: left;
    background: rgba(0,0,0,0.6);
    filter: progid:DXImageTransform.Microsoft.gradient(GradientType = 0,startColorstr = "#60000000",endColorstr = "#60000000")
    }.mod18 .picBox {
    height: 415px;
    position: relative;
    overflow: hidden
    }.mod18 .picBox ul {
    height: 415px;
    position: absolute
    }.mod18 .picBox li {
    width: 599px;
    height: 415px
    }.mod18 .listBox {
    width: 580px;
    height: 60px;
    margin: 0 auto;
    position: relative;
    padding: 6px 0 10px;
    overflow: hidden
    }.mod18 .listBox ul {
    height: 60px;
    position: absolute
    }.mod18 .listBox li {
    width: 65px;
    height: 42px;
    padding-left: 10px;
    padding-top: 10px;
    cursor: pointer;
    position: relative
    }.mod18 .listBox li i {
    display: none
    }.mod18 .listBox li a {
    display: block;
    width: 60px;
    height: 42px
    }.mod18 .listBox li img {
    width: 65px;
    height: 42px
    }.mod18 .listBox .on img {
    width: 60px;
    height: 42px;
    border: 3px solid #f60
    }.mod18 .listBox .on i {
    display: block
    }.con {
    display: none
    }.content {
    width: 599px;
    float: left
    }
    </style>
    <div class="div">
    <div class="div_head">
    <ul>
    <li class="active">滚动1</li>
    <li>滚动2</li>
    </ul>
    </div>
    <div class="content">
    <div class="con" style="display:block;">
    <div class="mod18"> <span id="prev" class="btn prev"></span> <span id="next" class="btn next"></span> <span id="prevTop" class="btn prev"></span> <span id="nextTop" class="btn next"></span>
    <div id="picBox" class="picBox">
    <ul class="cf">
    <li> <a href="#" target="_blank"><img width="700" height="465" src="images/tu1.jpg" /></a> <span>111</span> </li>
    <li> <a href="#" target="_blank" ><img width="700" height="465" src="images/tu2.jpg"  /></a> <span> 222</span> </li>
    <li> <a href="#" target="_blank"><img width="700" height="465" src="images/tu3.jpg" /></a> <span>33</span> </li>
    <li> <a href="http://www.17sucai.com/" target="_blank"><img width="700" height="465" src="images/tu4.jpg" /></a> <span>4444</span> </li>
    <li> <a href="#" target="_blank"><img width="700" height="465" src="images/tu1.jpg" /></a> <span>5</span> </li>
    </ul>
    </div>
    <div id="listBox" class="listBox">
    <ul class="cf">
    <li class="on"><i class="arr2"></i><img width="118" height="64" src="images/tu1.jpg" /></li>
    <li><i class="arr2"></i><img width="118" height="64" src="images/tu2.jpg" /></li>
    <li><i class="arr2"></i><img width="118" height="64" src="images/tu3.jpg" /></li>
    <li><i class="arr2"></i><img width="118" height="64" src="images/tu4.jpg" /></li>
    <li><i class="arr2"></i><img width="118" height="64" src="images/tu1.jpg" /></li>
    </ul>
    </div>
    </div>
    </div>
    <div class="con">
    <div class="mod18"> <span id="prev1" class="btn prev"></span> <span id="next1" class="btn next"></span> <span id="prevTop1" class="btn prev"></span> <span id="nextTop1" class="btn next"></span>
    <div id="picBox1" class="picBox">
    <ul class="cf">
    <li> <a href="#" target="_blank"><img width="700" height="465" src="images/tu1.jpg" /></a> <span>111</span> </li>
    <li> <a href="#" target="_blank" ><img width="700" height="465" src="images/tu2.jpg"  /></a> <span> 222</span> </li>
    <li> <a href="#" target="_blank"><img width="700" height="465" src="images/tu3.jpg" /></a> <span>33</span> </li>
    <li> <a href="http://www.17sucai.com/" target="_blank"><img width="700" height="465" src="images/tu4.jpg" /></a> <span>4444</span> </li>
    <li> <a href="#" target="_blank"><img width="700" height="465" src="images/tu1.jpg" /></a> <span>5</span> </li>
    </ul>
    </div>
    <div id="listBox1" class="listBox">
    <ul class="cf">
    <li class="on"><i class="arr2"></i><img width="118" height="64" src="images/tu1.jpg" /></li>
    <li><i class="arr2"></i><img width="118" height="64" src="images/tu2.jpg" /></li>
    <li><i class="arr2"></i><img width="118" height="64" src="images/tu3.jpg" /></li>
    <li><i class="arr2"></i><img width="118" height="64" src="images/tu4.jpg" /></li>
    <li><i class="arr2"></i><img width="118" height="64" src="images/tu1.jpg" /></li>
    </ul>
    </div>
    </div>
    </div>
    </div>
    </div>
    <script type="text/javascript">
    function getStyle(obj, attr){
    if(obj.currentStyle){
    return obj.currentStyle[attr];
    }else{
    return getComputedStyle(obj, false)[attr];
    }
    }
    function Animate(obj, json){
    if(obj.timer){
    clearInterval(obj.timer);
    }
    obj.timer = setInterval(function(){
    for(var attr in json){
    var iCur = parseInt(getStyle(obj, attr));
    iCur = iCur ? iCur : 0;
    var iSpeed = (json[attr] - iCur) / 5;
    iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
    obj.style[attr] = iCur + iSpeed + 'px';
    if(iCur == json[attr]){
    clearInterval(obj.timer);
    }
    }
    }, 30);
    }
    function huadong(picb,listb,prev,next,pret,nextt){
    var oPic = document.getElementById(picb);
    var oList = document.getElementById(listb);

    var oPrev = document.getElementById(prev);
    var oNext = document.getElementById(next);
    var oPrevTop = document.getElementById(pret);
    var oNextTop = document.getElementById(nextt); var oPicLi = oPic.getElementsByTagName("li");
    var oListLi = oList.getElementsByTagName("li");
    var len1 = oPicLi.length;
    var len2 = oListLi.length;

    var oPicUl = oPic.getElementsByTagName("ul")[0];
    var oListUl = oList.getElementsByTagName("ul")[0];
    var w1 = oPicLi[0].offsetWidth;
    var w2 = oListLi[0].offsetWidth; oPicUl.style.width = w1 * len1 + "px";
    oListUl.style.width = w2 * len2 + "px";
    var index = 0;

    var num = 5;
    var num2 = Math.ceil(num / 2); function Change(){ Animate(oPicUl, {left: - index * w1});

    if(index < num2){
    Animate(oListUl, {left: 0});
    }else if(index + num2 <= len2){
    Animate(oListUl, {left: - (index - num2 + 1) * w2});
    }else{
    Animate(oListUl, {left: - (len2 - num) * w2});
    } for (var i = 0; i < len2; i++) {
    oListLi[i].className = "";
    if(i == index){
    oListLi[i].className = "on";
    }
    }
    }

    oNextTop.onclick = oNext.onclick = function(){
    index ++;
    index = index == len2 ? 0 : index;
    Change();
    } oPrevTop.onclick = oPrev.onclick = function(){
    index --;
    index = index == -1 ? len2 -1 : index;
    Change();
    } for (var i = 0; i < len2; i++) {
    oListLi[i].index = i;
    oListLi[i].onclick = function(){
    index = this.index;
    Change();
    }
    }

    }
    </script>
    </body>
    </html>