2012-04-03 65 views
1

我有一个div,然后是uljQuery SlideUp在Chrome中无法正常工作

我将slideDown应用于div,并且在所有浏览器中都很好地将ul向下推。

然而,当我申请slideUpdiv,在所有broswers的ul很好div已经完成向上滑动后出现,但在Chrome中,ul出现div是向上滑动,然后看起来很混乱几秒钟,直到div消失。

你可以看到一个例子here

slideDownslideUp被激活,当您点击此图片: enter image description here

它使这个div出现或消失: enter image description here

这是ul,当div出现并消失时,应该是down and up,分别为: enter image description here

这里是代码。该HTML:

<div class="clearfix" id="whatWhere"> 
<ul> 
<!--what--> 
    <li id="what"> 
     <span>מה</span> 
     <div class="list"> 
      <ul class=""> 
       <li class="orange"><a href="http://dev.linux.ort.org.il/colleges?cat=7">אדריכלות ועיצוב פנים</a></li> 
       <li class="gray"><a href="http://dev.linux.ort.org.il/colleges?cat=14">אלקטרוניקה</a></li> 
       </ul>  
      <div class="toClose"> 
      <img width="37" height="18" src="http://dev.linux.ort.org.il/colleges/wp-content/themes/twentyeleven/images/close.png"> 
      </div> 
      </div><!--end list--> 
    </li> 
<!-- where --> 
    <li id="where"> 
      <span>איפה</span> 
      <div class="list"> 
      <ul class=""> 
       <li class="orange"><a href="http://dev.linux.ort.org.il/colleges/?p=21">מכללת אורט כפר סבא</a></li> 
       <li class="gray"><a href="http://dev.linux.ort.org.il/colleges/?p=19">מכללת אורט קרית ביאליק</a></li> 
      </ul> 

       <div class="toClose"> 
      <img width="37" height="18" src="http://dev.linux.ort.org.il/colleges/wp-content/themes/twentyeleven/images/close.png"> 
      </div> 
       </div><!--end list--> 
    </li> 
    </ul> 
</div> 

<ul id="links"> 
    <li id="hashlama"><a href="http://dev.linux.ort.org.il/colleges/?p=161">השלמה לתואר ראשון להנדסאים</a></li> 
    <li id="michlalot"><a href="http://dev.linux.ort.org.il/colleges/?p=165">מכללות אקדמיות להנדסה</a></li> 
</ul> 

这是JavaScript:

    $(document).ready(function() { 
        $("#whatWhere ul li span").click(function() { 
         //if another li open- closed; 
        if($(this).parent().siblings().children(".list").hasClass("highlight")){ 
         // $(this).parent().siblings().children("ul").slideUp("slow"); 
         $(this).parent().siblings().children(".list").css("display","none"); 
         $(this).parent().siblings().removeClass("open"); 
         $(this).parent().siblings().addClass("standBy"); 
         $(this).parent().siblings().children(".list").toggleClass("highlight"); 
        } 
        //open ul of selected li area 
        $(this).next().toggleClass("highlight"); 
        if($(this).next().hasClass("highlight")) 
         { 
         //#whatWhere 
          $(this).parent().parent().parent().addClass("open"); 
          //li 
          $(this).parent().addClass("open"); 
          $(this).next().slideDown("slow"); 
          $(this).parent().siblings().addClass("standBy"); 
          $(this).parent().removeClass("standBy"); 
         } 
        else 
         { 
         $(this).parent().parent().parent().removeClass("open"); 
         //li 
          $(this).parent().removeClass("open"); 
         $(this).next().slideUp("slow"); 
         // $(this).next().css("display","none"); 
         $(this).parent().siblings().removeClass("standBy"); 
         $(this).parent().removeClass("standBy"); 
         } 
        }); 

        $("#whatWhere ul li .list div.toClose").click(function() { 
         $(this).parent().parent().parent().parent().removeClass("open"); /*div #whatWhere*/ 
          $(this).parent().parent().removeClass("open"); /*li #what/#where*/ 
         $(this).parent().slideUp("slow"); 

         $(this).parent().parent().siblings().removeClass("standBy");/* the other li #what/#where*/ 
          $(this).parent().toggleClass("highlight"); /* div .list - maybe not needed*/ 
        }); 
       }); 
+0

总是发布相关的标记和代码**在问题本身**,不要只是链接(*也*链接是好的)。为什么:http://meta.stackexchange.com/questions/118392/add-stack-overfow-faq-entry-or-similar-forputing-code-in-the-question – 2012-04-03 08:49:27

+0

@ T.J。 Crowder你是对的,我通常这样做,但是这次代码太长了(HTML和JS),我害怕它会混淆而不是帮助... – 2012-04-03 08:58:40

+1

@ Lea:还是更好的包含它。只要确保您的实际问题位于顶部,然后将代码和标记粘贴到底部即可。就目前来看,这个问题对于将来有类似问题的任何人都是没用的。 – 2012-04-03 09:33:58

回答

3

将“height:auto”添加到ID为“whatWhere”的div中并且它应该可以正常工作。

+0

非常感谢@helmus,解决了问题!你能解释一下你是如何得到这个解决方案的? – 2012-04-03 10:57:47

+1

很高兴我能帮助Lea!我使用chrome dev工具来监视动画过程中发生的变化。然后我注意到,“style.css”中的“open”css类在div崩溃之前被删除,该类具有“height:auto”作为其样式属性之一,更改whatWhere类以匹配它,然后修复问题。 – 2012-04-03 11:11:02

+0

谢谢@helmus! – 2012-04-03 11:13:32

1

This家伙似乎已完成了在Chrome中运行。

+0

谢谢,但这对我的情况没有什么帮助,因为应用的元素已经是div – 2012-04-03 09:01:11

+0

,但滚动也正常工作:-) – santa 2012-04-03 09:02:25

+0

根据@ helmus的回答 – 2012-04-03 09:03:14

0

您应该在显示div的回调中添加显示ul

$('#yourDiv').slideUp(normal, function() { 
    $('#yourUl').slideDown(); 
}); 
+2

谢谢,但我宁愿不使用JS来修复似乎真的是CSS问题 – 2012-04-03 10:22:14

+0

这是一个公平的点 – fragmentedreality 2012-04-03 10:27:40

相关问题