메뉴 건너뛰기

HEUKMYO

program1

140812_[jquery] show(slide)

2014.09.23 21:00 read.316

예제1

jq_slide_2.gif


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
32
33
34
35
36
37
38
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ko" xml:lang="ko">
    <head>
        <meta http-equiv="content-type" content="text/html;charset=utf-8" />
        <title> new document </title>
        <style type="text/css">
            div{display:none;background:red;height:200px}
            .a, .b{display:none;float:left;background-color:green;}
        </style>
        <script src="http://code.jquery.com/jquery-1.10.2.js" type="text/javascript"></script>
        <script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js" type="text/javascript"></script>
        <script type="text/javascript">
        //<![CDATA[
            $(document).ready(function(){
                $("div").show("slide",{direction:"left"},1000,function(){
                    $('.a').show("slide",{direction:"left"},1000,function(){
                        $('.b').show("slide",{direction:"left"},1000,null);
                    });
                });
            });
        //]]>
        </script>
    </head>
    <body>
        <div>
            <ul class="a">
                <li>menu1</li>
                <li>menu2</li>
                <li>menu3</li>
            </ul>
            <ul class="b">
                <li>menu11</li>
                <li>menu12</li>
                <li>menu13</li>
            </ul>
        </div>
    </body>
</html>


예제2

jq_slide_3.gif


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
32
33
34
35
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ko" xml:lang="ko">
    <head>
        <meta http-equiv="content-type" content="text/html;charset=utf-8" />
        <title> new document </title>
        <style type="text/css">
            div{display:none;margin-bottom:10px;background:red;height:50px}
            .a,.e{width:50px;}
            .b,.f{width:100px;}
            .c,.g{width:150px;}
            .d,.h{width:200px;}
        </style>
        <script src="http://code.jquery.com/jquery-1.10.2.js" type="text/javascript"></script>
        <script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js" type="text/javascript"></script>
        <script type="text/javascript">
        //<![CDATA[
            $(document).ready(function(){
                $(".a").show("slide",{direction:"left"},1000,function(){
                    $(".b").show("slide",{direction:"left"},1000,function(){
                        $(".c").show("slide",{direction:"left"},1000,function(){
                            $(".d").show("slide",{direction:"left"},1000,null)
                        });
                    });
                });
            });
        //]]>
        </script>
    </head>
    <body>
        <div class="a"></div>
        <div class="b"></div>
        <div class="c"></div>
        <div class="d"></div>
    </body>
</html>



예제3

이미지를 클릭하면 슬라이드 됨

jq_slide_4.gif


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
32
33
34
35
36
37
38
39
40
41
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ko" xml:lang="ko">
    <head>
        <meta http-equiv="content-type" content="text/html;charset=utf-8" />
        <title> new document </title>
        <style type="text/css">
            *{margin:0;padding:0;}
            div{position: absolute;}
        </style>
        <script src="http://code.jquery.com/jquery-1.10.2.js" type="text/javascript"></script>
        <script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js" type="text/javascript"></script>
        <script type="text/javascript">
        //<![CDATA[
            $(document).ready(function(){
                var count=0;
                $('.b').hide();
                $('div').click(function(){
                    $('.a').hide("slide",{direction:"left"},500);
                    $('.b').show("slide",{direction:"right"},500,function(){
                        $('.a').show();
                        $('.b').hide();
                        if(count==0){
                            $('.a img').attr("src","images/img_02.jpg");
                            $('.b img').attr("src","images/img_01.jpg");
                            count=1;
                        }else{
                            $('.a img').attr("src","images/img_01.jpg");
                            $('.b img').attr("src","images/img_02.jpg");
                            count=0;
                        }
                    });
                });
            });
        //]]>
        </script>
    </head>
    <body>
        <div class="a"><img src="images/img_01.jpg" alt="" /></div>
        <div class="b"><img src="images/img_02.jpg" alt="" /></div>
    </body>
</html>



예제4

jq_slide_5.gif


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
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ko" xml:lang="ko">
    <head>
        <meta http-equiv="content-type" content="text/html;charset=utf-8" />
        <title> new document </title>
        <style type="text/css">
            *{margin:0;padding:0;}
            div{float:left;}
            div img{height:268px}
        </style>
        <script src="http://code.jquery.com/jquery-1.10.2.js" type="text/javascript"></script>
        <script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js" type="text/javascript"></script>
        <script type="text/javascript">
        //<![CDATA[
            $(document).ready(function(){
                /* $(".b").hide(); */
                var count=0;
                $(".b img").css("width",0);
                $("div").click(function(){
                    $(".a img").animate({width:0},1000);
                    $(".b img").animate({width:188},1000,function(){
                        $(".a img").css("width","188"); //초기화 시켜줌
                        $(".b img").css("width","0"); //초기화 시켜줌
                        if(count==0){
                            $(".a img").attr("src","images/img_02.jpg");
                            $(".b img").attr("src","images/img_01.jpg");
                            count=1;
                        }else{
                            $(".a img").attr("src","images/img_01.jpg");
                            $(".b img").attr("src","images/img_02.jpg");
                            count=0;
                        }
                    });
                });
            });
        //]]>
        </script>
    </head>
    <body>
        <div class="a"><img src="images/img_01.jpg" alt="" /></div>
        <div class="b"><img src="images/img_02.jpg" alt="" /></div>
    </body>
</html>






위로