활성화된 버튼별로 원하는 줄만 출력하려고 합니다..

활성화된 버튼별로 원하는 줄만 출력하려고 합니다..

QA

활성화된 버튼별로 원하는 줄만 출력하려고 합니다..

본문

3659974726_1616030127.3929.png

 

위와 같이 1~3번 버튼이 있고 제일 처음에는 1~3 버튼만 보이고

1번 버튼을 누르면 1번에 포함된 2개 줄이 나오고

 

2번 버튼을 누르면 1번 줄은 숨겨지고 2번 줄이 나오게 하려면 어떻게 해야될 까요..

 

tr td가 여러개라 어떻게 해야될지... 도와주세요

이 질문에 댓글 쓰기 :

답변 2



<table border=1>
<tr class='c1' style='display:none'>
    <td>1-1-1</td><td>1-1-2</td><td>1-1-3</td>
</tr>
<tr class='c1' style='display:none'>
    <td>1-2-1</td><td>1-2-2</td><td>1-2-3</td>
</tr>
<tr class='c2' style='display:none'>
    <td>2-1-1</td><td>2-1-2</td><td>2-1-3</td>
</tr> <tr class='c2' style='display:none'>
    <td>2-2-1</td><td>2-2-2</td><td>2-2-3</td>
</tr>
<tr class='c3' style='display:none'>
    <td>3-1-1</td><td>3-1-2</td><td>3-1-3</td>
</tr> <tr class='c3' style='display:none'>
    <td>3-2-1</td><td>3-2-2</td><td>3-2-3</td>
</tr>
</table>
<button class='btn' showTr='c1'>버튼1</button>
<button class='btn' showTr='c2'>버튼2</button>
<button class='btn' showTr='c3'>버튼3</button>
<script>
$(".btn").click(function(){
    
  var showTr = $(this).attr("showTr");
  $('tr').hide();
  $("."+showTr).show(); // 선택된것만 보이게
});
</script>
답변을 작성하시기 전에 로그인 해주세요.
전체 123,532 | RSS
QA 내용 검색

회원로그인

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