모바일 토글 클래스 질문 드립니다. 채택완료

안녕하세요 그누보드 5 회원여러분 코딩에 좀 문제가 있는지 ,,질문좀 드립니다.



모바일 버전 메뉴 수정을 하고 있습니다. 


Copy
<div id="gnb" class="hd_div">            <ul id="gnb_1dul">            <?php            $sql = " select *                        from {$g5['menu_table']}                        where me_mobile_use = '1'                          and length(me_code) = '2'                        order by me_order, me_id ";            $result = sql_query($sql, false);            for($i=0; $row=sql_fetch_array($result); $i++) {            ?>                <li class="gnb_1dli">                    <a href="<?php echo $row['me_link']; ?>" target="_<?php echo $row['me_target']; ?>" class="gnb_1da"><?php echo $row['me_name'] ?><span class="menumore"><i style="float:right;" class="fa fa-plus" aria-hidden="true"></i></span></a>                    <?php                    $sql2 = " select *                                from {$g5['menu_table']}                                where me_mobile_use = '1'                                  and length(me_code) = '4'                                  and substring(me_code, 1, 2) = '{$row['me_code']}'                                order by me_order, me_id ";                    $result2 = sql_query($sql2);                    for ($k=0; $row2=sql_fetch_array($result2); $k++) {                        if($k == 0)                            echo '<ul class="gnb_2dul">'.PHP_EOL;                    ?>                        <li class="gnb_2dli"><a href="<?php echo $row2['me_link']; ?>" target="_<?php echo $row2['me_target']; ?>" class="gnb_2da"><span></span><?php echo $row2['me_name'] ?></a></li>                    <?php                    }                    if($k > 0)                        echo '</ul>'.PHP_EOL;                    ?>                </li>            <?php            }            if ($i == 0) {  ?>                <li id="gnb_empty">메뉴 준비 중입니다.<?php if ($is_admin) { ?> <br><a href="<?php echo G5_ADMIN_URL; ?>/menu_list.php">관리자모드 &gt; 환경설정 &gt; 메뉴설정</a>에서 설정하세요.<?php } ?></li>            <?php } ?>            </ul>            <button type="button" id="gnb_close" class="hd_closer"><span class="sound_only">메뉴 </span>닫기</button>        </div>



현재 모바일은 기본베이직처럼 똑같구 큰메뉴 하나 작은메뉴가 하단에 보이도록 바로 설정이 되어있습니다. 


작은메뉴는들은 안보이는상태이구 .menumore 클릭했으실에 개별로 하나하나 나오게 토글클래스를 짜고 싶은데 어떻게 짜야할지 문제 입니다.



f3ec6e25a1e0336003c467f9e8b3e4bf_1499843997_9016.png
 


Copy
<script>$( ".menumore" ).click(function() {  $( ".gnb_2dul" ).toggle( "slow" );});</script>

답변 4개

채택된 답변
+20 포인트
Copy
<script>$( ".menumore" ).click(function() {  	$(this).closest(".gnb_1dli").find(".gnb_2dul").toggle( "slow" );});</script>
로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

감사합니다

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

<script>

$(function () {

$(".gnb_2dul").hide();

$(".menumore").click(function() {

 $(".gnb_2dul", this).toggle("slow");

});

});

</script>

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

<script>

$(function () {

$(".gnb_2dul").hide();

$(".menumore").click(function() {

 $(".gnb_2dul", this).toggle("slow");

});

});

</script>

로그인 후 평가할 수 있습니다

답변에 대한 댓글 2개

답변 감사합니다.

jquery.menu.js:92 Uncaught TypeError: $gnb_1dli.find(...).size is not a function
at menu_rearrange (jquery.menu.js:92)
at HTMLAnchorElement.<anonymous> (jquery.menu.js:24)
at HTMLAnchorElement.dispatch (jquery-3.2.1.min.js:3)
at HTMLAnchorElement.q.handle (jquery-3.2.1.min.js:3)

이렇게 콘솔 오류가 뜨는데 원인이 무엇일까요..?
<script>
$(".gnb_2dul").hide();
$(".menumore").click(function() {
$(".gnb_2dul", this).toggle("slow");
});
</script>

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고