jquery 드롭다운메뉴 질문입니다.

· 13년 전 · 3859
index 파일입니다.
<!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">
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=euc-kr" />
 <title></title>
 <link type="text/css" rel="stylesheet" href="type/common.css" />
 <script type="text/javascript" src="type/jquery-1.7.2.min.js"></script>
</head>
<body>
 <div id="header">
  <h1><a href="/"><img src="image/logo.jpg"  /></a></h1>
  <div class="navigation">
   <ul class="topnav">
    <li><a href="#">회사소개</a>
     <ul class="subnav">
      <li><a href="#">Sub Nav Link</a></li>
      <li><a href="#">Sub Nav Link</a></li>
     </ul>
    </li>
    <li><a href="#">사업개요</a>
     <ul class="subnav">
      <li><a href="#">Sub Nav Link</a></li>
      <li><a href="#">Sub Nav Link</a></li>
     </ul>
    </li>
   </ul>
  </div>
  
 <script>
 $(document).ready(function(){
 $("ul.subnav").parent().append("<span></span>");
    $("ul.topnav li").mouseover(function() {
        $(this).parent().find("ul.subnav").slideDown('fast').show();
        $(this).parent().hover(function() {  
        }, function(){    
            $(this).parent().find("ul.subnav").slideUp('slow');
        });  
        }).hover(function() {   
            $(this).addClass("subhover");
        }, function(){
            $(this).removeClass("subhover");
  });  
 }); 
 </script>
</body>
</html>
 
css파일입니다.
/*navigation*/
ul.topnav {padding:0 20px; margin:0; width:920px; background:#222; font-size:1.2em; background:url() repeat-x;}
ul.topnav li {margin:0; padding:0 15px 0 0; position:relative;}
ul.topnav li a {padding:10px 5px; color:#29f483; display:block; text-decoration:none; float:left;}  
ul.topnav li a:hover {background:url() no-repeat center top;}
/*ul.topnav li span {width:17px; height:35px; float:left; background:url(1.jpg) no-repeat center top;}*/
/*ul.topnav li span.subhover {background-position:center bottombottom; cursor:pointer;}*/
ul.topnav li ul.subnav {position:absolute; left:0; top:35px; background:#333; margin:0; padding:0; display:none; float:left; width:170px; border:1px solid #111;}
ul.topnav li ul.subnav li{margin:0; padding:0; border-top:1px solid #252525; border-bottom:1px solid #444; clear:both; width:170px;}
html ul.topnav li ul.subnav li a {float:left; width:145px; background:#333 url() no-repeat 10px center; padding-left:20px;} html ul.topnav li ul.subnav li a:hover {background:#222 url() no-repeat 10px center;}
 
원래 소스는 메뉴 옆 빈공간을 만들어 클릭시에 메뉴가 드롭다운 되게 하는 구조입니다.
제가 수정한 부분은 bold처리 된 부분이며, 위 소스대로 수정 후 실행시 아시다시피 모든 메뉴가 한번에 드롭다운 됩니다.
메뉴에 마우스 오버를 했을 시 마우스오버 된 메뉴의 서브메뉴만 노출되게 하고 싶습니다.
조언부탁드립니다.
 
html의 script 수정부분은 ul.topnav li span 부분을 ul.topnav li 로 수정하였으며, css는 수정하지 않았으며 주석처리만 해놓았습니다.
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
13년 전 조회 2,800
13년 전 조회 3,744
13년 전 조회 1,419
13년 전 조회 2,929
13년 전 조회 2,272
13년 전 조회 4,071
13년 전 조회 4,124
13년 전 조회 1,936
13년 전 조회 4,945
13년 전 조회 2,066
13년 전 조회 2,222
13년 전 조회 2,689
13년 전 조회 2,626
13년 전 조회 1,705
13년 전 조회 1,871
13년 전 조회 3,792
13년 전 조회 1,868
13년 전 조회 2,355
13년 전 조회 3,163
13년 전 조회 2,964
13년 전 조회 1,692
13년 전 조회 2,318
13년 전 조회 4,652
13년 전 조회 1,964
13년 전 조회 2,412
13년 전 조회 1,926
13년 전 조회 2,119
13년 전 조회 2,561
13년 전 조회 1,658
13년 전 조회 2,575
13년 전 조회 2,216
13년 전 조회 1,770
13년 전 조회 1만
13년 전 조회 1,893
13년 전 조회 1,755
13년 전 조회 1,844
13년 전 조회 2,573
13년 전 조회 1,925
13년 전 조회 2,051
13년 전 조회 1,699
13년 전 조회 1,540
13년 전 조회 5,669
13년 전 조회 1,965
13년 전 조회 1,997
13년 전 조회 1,830
13년 전 조회 7,701
13년 전 조회 1,858
13년 전 조회 2,196
13년 전 조회 2,148
13년 전 조회 3,860
13년 전 조회 1,902
13년 전 조회 3,696
13년 전 조회 2,242
13년 전 조회 2,797
13년 전 조회 2,334
13년 전 조회 2,506
13년 전 조회 2,759
13년 전 조회 1,564
13년 전 조회 1,761
13년 전 조회 1,767
13년 전 조회 2,075
13년 전 조회 2,118
13년 전 조회 2,840
13년 전 조회 1,726
13년 전 조회 1,780
13년 전 조회 4,198
13년 전 조회 1,909
13년 전 조회 2,170
13년 전 조회 2,583
13년 전 조회 2,040
13년 전 조회 2,966
13년 전 조회 1,716
13년 전 조회 3,796
13년 전 조회 2,218
13년 전 조회 2,482
13년 전 조회 1,926
13년 전 조회 2,064
13년 전 조회 2,466
13년 전 조회 2,149
13년 전 조회 2,674
13년 전 조회 2,460
13년 전 조회 1,751
13년 전 조회 3,817
13년 전 조회 1,945
13년 전 조회 3,012
13년 전 조회 1,872
13년 전 조회 2,960
13년 전 조회 2,825
13년 전 조회 2,836
13년 전 조회 1,801
13년 전 조회 2,344
13년 전 조회 2,095
13년 전 조회 3,051
13년 전 조회 1,951
13년 전 조회 1,962
13년 전 조회 2,247
13년 전 조회 1,978
13년 전 조회 1,936
13년 전 조회 3,308
13년 전 조회 2,110