티스토리 뷰

노트/JS

맨 위로(Top) 버튼

태엽푸는새 2016. 8. 21. 21:20
<div id="<?=$uid=uniqid()?>">
    <img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRyjSgmd0Hx9rY7AsO7LFDsU0w9RFELuxrh6DBExerWVTMDzt2NUw">
</div>

<script>
$(function() {
    var $uid = $('#<?=$uid?>');
   
    $uid.css({
        position:'fixed',
        right:'50px',
        bottom:'50px',
        zIndex:'999999'
    }).hide().find('>img').css({
        cursor:'pointer'
    }).click(function() {
        scrollTo(0, 0);
    });
   
    $(window).scroll(function() {
        var y = $(window).scrollTop();
        if (y > 300 && $uid.is(':hidden'))
            $uid.fadeIn('slow');
        else if (y < 300 && $uid.is(':visible'))
            $uid.fadeOut('slow');
    });
});
</script>


'노트 > JS' 카테고리의 다른 글

Get Selected Text  (0) 2016.09.09
beep  (0) 2016.08.18
number_format  (0) 2016.08.18
refresh  (0) 2016.08.18
contenteditable  (0) 2016.08.18
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함