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 回答