테스트 사이트 - 개발 중인 베타 버전입니다

버튼 클릭 시 숨겨진 tr / td 표 나오기 채택완료

qwqweqwe 4년 전 조회 3,882

1~9번 버튼이 있다면 1번 버튼 클릭 시 tr td 표가 나오고

 

다음 2번 버튼을 클릭했을 때는 2번에 맞는 표가 나오게 하고 싶습니다..

 

혹시 간단하게 구현할 수 있는 방법 있을까요?

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

답변 2개

채택된 답변
+20 포인트

버튼마다 onclick 넣고 id로 연결시켜서 show/hide 시켜보세요

 

jquery show/hide로 검색해보세요

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

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

4년 전

</p>

<p>    <button type="button" data-table="table_01"></button></p>

<p>    <button type="button" data-table="table_02"></button></p>

<p>    <button type="button" data-table="table_03"></button></p>

<p>    <div class="tab_area"></p>

<p>        <table class="table_01"></table></p>

<p>        <table class="table_02"></table></p>

<p>        <table class="table_03"></table></p>

<p>    </div></p>

<p>    <style></p>

<p>        [class*='table_0']{display:none;}</p>

<p>        [class*='table_0'].active{display:block;}</p>

<p>    </style></p>

<p>    <script></p>

<p>        $(function(){</p>

<p>            $('button').click(function(){</p>

<p>                var $target = $(this).attr('data-table');</p>

<p>                $('.tab_area').children('table').removeClass('active');</p>

<p>                $('.'+$target).addClass('active');</p>

<p>            });</p>

<p>        });</p>

<p>    </script></p>

<p>

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

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

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

로그인