0

Ok so heres my problem: I need the top div to only slide up/down when the mediaPlayerWrapper is there and not when the content_text is there. both are created using Ajax and php and only one exists at a time. As per my code bellow it works fine in the mediaPlayerWrapper but unfortunately it still slides in the content_text. any Ideas?

$(document).ready(function(){

    $("#main_content").ajaxStop(function(){

        if ($("#content_text").length){ 
        }

        else if($("#mediaPlayerWrapper").length){// Slide top and bottom bars when video wrapper is displayed
            $("#top").slideUp(2000); //slide up(hide) DIV's


                var timer;

                $('html').mousemove(function(e) { //slide(show) DIV's down on mouse move
                    if(window.lastX !== e.clientX || window.lastY !== e.clientY){   //Check to see if mouse has moved before running code
                        $('#top').slideDown(2000);                      


                        clearTimeout(timer);
                        timer = setTimeout(function(){
                                            $('#top').slideUp(2000)//<--- this is the line that is causing the problem
                                                }, 5000);//slide back up after 5 seconds
                        }

                        window.lastX = e.clientX //stores the current x coordinate
                        window.lastY = e.clientY // stores the current y coordinate
                    }); 
        }

    }); 

sorry I cannot provide a fiddle or link to the site. });

4

1 に答える 1

0

なんらかの理由で長さが適切に機能しない場合は、いつでも「.addClass()」を使用して「is_shown」などを追加し、「.hasClass('is_shown')」を使用してチェックすることができます。このメソッドを使用すると、ajax 関数で DOM に追加または削除されない追加の親/ラッパーが必要になる場合があります。

于 2012-10-18T00:53:19.410 に答える