티스토리 뷰

반응형
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .tab-menu {
             list-style: none;
             height:80px;
         }
         
         .tab-menu li {
             width:99px;
             height:40px;
             background-position-y:0;
             text-indent: -1000px;
             overflow: hidden;
             display: inline-block;
             float:left;
         }
        .tab-menu li:hover {
            background-position-y: -40px;
        }
        .tab-menu li.select {
            background-position-y: -80px;
            height: 80px;
        }
         .tab-menu li.menuitem1 {
             background-image: url(image/newbtn.bar.1.png);    
         }
         .tab-menu li.menuitem2 {
             background-image: url(image/newbtn.bar.2.png);    
         }
         .tab-menu li.menuitem3 {
             background-image: url(image/newbtn.bar.3.png);    
         }
         .tab-menu li.menuitem4 {
             background-image: url(image/newbtn.bar.4.png);    
         }
         .tab-menu li.menuitem5 {
             background-image: url(image/newbtn.bar.6.png);    
         }
     </style>
    <script>
        function returnIndex(){
          return $("#tabMenu1 li").filter(".select").index();
        }  
 
        var chk = false;
        function a (index){
            switch(index){
                case 0:                
                 $("#tabMenu1 .menuitem1").addClass("select");
                 $("div").html('<img src="image/content_facebook.png" alian="bottom">');                              
                 break;
                case 1:     
                 $("#tabMenu1 .menuitem2").addClass("select");
                 $("div").html('<img src="image/content_google.png" alian="bottom">');
                  break;
                case 2:     
                 $("#tabMenu1 .menuitem3").addClass("select");
                 $("div").html('<img src="image/content_pinterest.png" alian="bottom">');
                 break;
                case 3:
                  $("#tabMenu1 .menuitem4").addClass("select");     
                 $("div").html('<img src="image/content_twitter.png" alian="bottom">');
                 break;
                case 4:  
                 $("#tabMenu1 .menuitem5").addClass("select");   
                 $("div").html('<img src="image/content_path.png" alian="bottom">');
                  break;               
            }                
        }
 
        $(document).ready(function(){ 
            tabMenu("#tabMenu1",a);   
            $("input").click(function(){
                rmClass();
            })
 
        });
 
        function tabMenu(selector,callback){//라이브러리.          
            $("li").click(function(){//이벤트
                 callback($(this).index());                         
            });
            
        };
 
        function rmClass(){
          var chk = returnIndex();
          $("#tabMenu1 li").eq(chk).removeClass("select");
   
        }
    </script>
 
</head>
<body>
        <ul class="tab-menu" id="tabMenu1">
            <li class="menuitem1">google</li>                
            <li class="menuitem2">facebook</li>
            <li class="menuitem3">pinterest</li>
            <li class="menuitem4">twitter</li>
            <li class="menuitem5">path</li>
        </ul>
        <input type="button" value="hi">
        <div>
        </div>    
        
</body>
</html>

 

버튼 누르면 지워지긴 하는데

클릭때마다 검사할 방법? 

반응형