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

· 13년 전 · 3398
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,296
13년 전 조회 3,206
13년 전 조회 914
13년 전 조회 2,420
13년 전 조회 1,807
13년 전 조회 3,556
13년 전 조회 3,615
13년 전 조회 1,425
13년 전 조회 4,424
13년 전 조회 1,546
13년 전 조회 1,692
13년 전 조회 2,212
13년 전 조회 2,137
13년 전 조회 1,181
13년 전 조회 1,367
13년 전 조회 3,289
13년 전 조회 1,388
13년 전 조회 1,830
13년 전 조회 2,622
13년 전 조회 2,448
13년 전 조회 1,199
13년 전 조회 1,803
13년 전 조회 4,140
13년 전 조회 1,466
13년 전 조회 1,904
13년 전 조회 1,413
13년 전 조회 1,609
13년 전 조회 2,026
13년 전 조회 1,181
13년 전 조회 2,048
13년 전 조회 1,678
13년 전 조회 1,279
13년 전 조회 9,642
13년 전 조회 1,377
13년 전 조회 1,268
13년 전 조회 1,327
13년 전 조회 2,057
13년 전 조회 1,448
13년 전 조회 1,527
13년 전 조회 1,182
13년 전 조회 1,036
13년 전 조회 5,182
13년 전 조회 1,441
13년 전 조회 1,462
13년 전 조회 1,284
13년 전 조회 7,211
13년 전 조회 1,334
13년 전 조회 1,707
13년 전 조회 1,649
13년 전 조회 3,399
13년 전 조회 1,370
13년 전 조회 3,208
13년 전 조회 1,745
13년 전 조회 2,267
13년 전 조회 1,787
13년 전 조회 2,000
13년 전 조회 2,232
13년 전 조회 1,048
13년 전 조회 1,253
13년 전 조회 1,247
13년 전 조회 1,567
13년 전 조회 1,603
13년 전 조회 2,369
13년 전 조회 1,212
13년 전 조회 1,290
13년 전 조회 3,675
13년 전 조회 1,380
13년 전 조회 1,665
13년 전 조회 2,091
13년 전 조회 1,525
13년 전 조회 2,449
13년 전 조회 1,222
13년 전 조회 3,281
13년 전 조회 1,730
13년 전 조회 1,956
13년 전 조회 1,417
13년 전 조회 1,556
13년 전 조회 1,939
13년 전 조회 1,629
13년 전 조회 2,167
13년 전 조회 2,017
13년 전 조회 1,216
13년 전 조회 3,297
13년 전 조회 1,450
13년 전 조회 2,517
13년 전 조회 1,357
13년 전 조회 2,453
13년 전 조회 2,294
13년 전 조회 2,328
13년 전 조회 1,293
13년 전 조회 1,843
13년 전 조회 1,559
13년 전 조회 2,546
13년 전 조회 1,469
13년 전 조회 1,470
13년 전 조회 1,735
13년 전 조회 1,482
13년 전 조회 1,426
13년 전 조회 2,779
13년 전 조회 1,602