slideUp only hides? can't show using slideUp

只愿长相守 提交于 2020-01-02 07:35:25

问题


#bannerFijo is a fixed banner display:none at bottom:0px; so to show it I should slideUp() but it seems that this is not working.

<script type="text/javascript">
    function mostrar_banner() {
        $('#bannerFijo').slideUp();
    }
    function ocultar_banner(){
        $('#bannerFijo').slideDown();
    }
    $(document).ready(function() {
        mostrar_banner();

        $('#bannerFijo .close').click(function() {
            ocultar_banner();
        });
    });
</script>

(and it does using show/hide)

 <script type="text/javascript">
    function mostrar_banner() {
        $('#bannerFijo').show();
    }
    function ocultar_banner(){
        $('#bannerFijo').hide();
    }
    $(document).ready(function() {
        mostrar_banner();

        $('#bannerFijo .close').click(function() {
            ocultar_banner();
        });
    });
</script>

I tried

$('#bannerFijo').show("slide", { direction: "up" }); 

to show it and I get an error in jquery.min.js.

o.easing[this.options.easing || (o.easing.swing ? "swing" : "linear")] is not a function  
[Detener en este error] (function(){var R=/((?:\((?:\([^()]+\)...ypeof K==="string"?K:K+"px")}})})();
jquery....min.js (línea 31)

Does anybody see an alternative here?

Here is a screenshot of the page for reference.


回答1:


You might be able to use animate to achieve this, depending on the location and style of the element:

$('#bannerFijo').animate({ height: desiredHeight }, lengthOfAnimation, function() {
    //executes on completion
});

Obviously you would need to define desiredHeight and lengthOfAnimation.




回答2:


Have you tried to just do slideDown to show and slideUp to hide? Even though what you seek is reverse in sense..

When you have element in bottom, and you do slideDown, its a show event with "slide" effect. Since its on bottom, the animation shows in reverse. Atleast to the eye. But its actually sliding down, and because it has hitted the bottom, it raises up.

EDIT: Heres jsFiddle example: http://jsfiddle.net/fddpp/




回答3:


Try using the slideToggle();

Maybe something like: http://jsfiddle.net/SCgdy/14/



来源:https://stackoverflow.com/questions/7121147/slideup-only-hides-cant-show-using-slideup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!