클릭이벤트 관련질문입니다.

클릭이벤트 관련질문입니다.

QA

클릭이벤트 관련질문입니다.

본문

배열로 넘어오는 최신글에 관하여 원글을 클릭시 원글에 대한 답변글을 나오게 하고싶은 슬라이드를

만들려고 하는데 계속 한부분이 걸려서 넘어가질않습니다 ㅜ  

원글을 클릭 시 해당하는 부분의 답변만 넘어와야 하는데 모든 답변이 다 나오네요 ㅜㅜ

하나하나 따로 나오게하는 방법이 있을까요 ? ㅜ 고수분들 부탁드립니다 ㅜ

 

밑에는 latest.skin 소스입니다.

 

<ul>
    <?php for ($i=0; $i<count($list); $i++) { 
    //해당 원글의 옆에 a태그로 답변을 달았기 때문에 답변을 클릭시 해당 글의 답변페이지로 가기위하여 $reply_href를 선언.
            $reply_href = G5_BBS_URL.'/write.php?w=r&bo_table='.$bo_table.'&wr_id='.$list[$i]['wr_id'].$qstr;
            //else
            //  echo " ".$list[$i]['subject'];
            // 답변글이 없다면 $list[$i]['subject']출력하라
            // 하지만 답변글이 있으므로 출력이 안됨.
            echo "<a  target='iframe_show' onclick='sink(this);' class='latest_st' href=\"".$list[$i]['href']."\">";   
                // 원글 옆의 답글 링크 부분
                // 관리자로 로그인 시 보여지게 셋팅
    if($is_admin) {
        if(!$list[$i]['wr_reply'])
                echo " ".$list[$i]['subject']."<a target='iframe_show' class='first_re' href='".$reply_href."'>추가</a><a class='latest_list_p'>+</a><a class='latest_list_m'>━</a>";
            } else {
                if(!$list[$i]['wr_reply'])
            echo " ".$list[$i]['subject']."<a class='latest_list_p'>+</a><a class='latest_list_m'>━</a>";
        }      
        echo "</a>";
        ?>
        <li> 
             <?php
            
            //답변글만 출력
            if($list[$i]['wr_reply']){
                echo "<a target='iframe_show' onclick='sink2(this)' class='latest_re'href=\"".$list[$i]['href']."\" >".$list[$i]['icon_reply']."  ";
            echo $list[$i]['subject']."";
            echo "<a target='iframe_show' class='second_re' href='".$reply_href."'>추가</a>";
            }
            echo "</a>";
            ?>
           <?php
           
            //코멘트
            if ($list[$i]['comment_cnt'])
                echo $list[$i]['comment_cnt'];
           

             //if ($list[$i]['link']['count']) { echo "[{$list[$i]['link']['count']}]"; }
             //if ($list[$i]['file']['count']) { echo "<{$list[$i]['file']['count']}>"; }

            //if (isset($list[$i]['icon_new'])) echo " " . $list[$i]['icon_new'];
            if (isset($list[$i]['icon_hot'])) echo " " . $list[$i]['icon_hot'];
            //if (isset($list[$i]['icon_file'])) echo " " . $list[$i]['icon_file'];
            if (isset($list[$i]['icon_link'])) echo " " . $list[$i]['icon_link'];
            if (isset($list[$i]['icon_secret'])) echo " " . $list[$i]['icon_secret'];
             ?>
        </li>
    <?php }  ?>
    <?php if (count($list) == 0) { //게시물이 없을 때  ?>
    <li>게시물이 없습니다.</li>
    <?php }  ?>
    </ul>

 

 

 

스크립트 소스입니다.

 

$(function (){
    $('.lt ul li a').hide();
    //$('.latest_re').hide();
    //$('.second_re').hide();
    $('.latest_list_m').hide();
    var latest_list_p = $('.latest_list_p');
    var latest_list_m = $('.latest_list_m');
    var latest_re = $('.latest_re');
    latest_list_p.click(function(){
        $('.lt ul li a').css("display", "inline");
        //$('.latest_re').slideDown();
        //$('.second_re').slideDown();
        $('.latest_list_p').hide();
        $('.latest_list_m').show();
       
    });
    latest_list_m.click(function(){
        $('.lt ul li a').hide();
        //$('.latest_re').slideUp();
        //$('.second_re').slideUp();
        $('.latest_list_p').show();
        $('.latest_list_m').hide();
       
    })
}); 

이 질문에 댓글 쓰기 :

답변 1

배열로 돌아가면서 모두 같은 class 를 사용하기에 문제되시는것 같습니다.

선택하는 부분에 대해 개별적으로 인식하게끔 작업하시던지 

다른방법을 찾아보셔야 할것 같습니다.

글쎄요... 저는 아에 만들어버려서 위의 소스만 봐서는 잘 모르겠구요
저의 경우 id 에 번호를 매기거나 data-row 속성을 하나 추가해서 각 선택자마다 순서 또는 키(?)를 부여하고
클릭시 해당 번호 또는 키값에 의해 숨겨진 특정 부분을 보이게끔 처리합니다.


$(".left_side_menu_table_td").hover(
    function(){
      $(".left_side_sub_menu").each(function(){
        $(this).hide();
      });
       $(".left_side_menu_table_td").each(function(){
        $(this).css("background","#3d4047");
      });
      if($(this).attr("data-row")){
        $("#left_side_menu_sub_"+$(this).attr("data-row")).show();
        $(this).css({"background":"#1c5ecb"});
      }
    }
  );

제가 썻던 코드입니다.
도움이 되었으면 좋겠네요

답변을 작성하시기 전에 로그인 해주세요.
전체 60,962
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT