user1310420
user1310420

Reputation:

Jquery SlideUp when page is scrolled

is there any way I can slideUp an element when the page is scrolled by the user in Jquery.

Thanks

Upvotes: 0

Views: 839

Answers (2)

Ryan Fiorini
Ryan Fiorini

Reputation: 800

jsfiddle

Give this a try.

<style>
#container {
    height:2000px;
    border:1px solid #000;
}


#imgContainer {
    position:relative;
}​
</style>

<script>
$(document).ready(function(){
    $(document).scroll(function() {
        var scrollTop = $(document).scrollTop();
        $("#imgContainer").animate({top:scrollTop+"px"},1000);
    });​
});​
</script>

<!-- making big to allow for scrolling -->
<div id="container">
    <div id="imgContainer"><img src="http://dummyimage.com/300x100/000000/ffffff&text=Watch+Me+Move">
    </div>
<div>​

Upvotes: 1

Ankur Verma
Ankur Verma

Reputation: 5933

<script>
    $(function() {
        $(window).scroll(function(){
            $('#Your element id').slideUp('slow');
        });

    });     
</script>

Upvotes: 1

Related Questions