본문 바로가기

JavaScript

[html/css/javaScript] 자바스크립트로 탭메뉴 만들기 tap menu

반응형

    <script type="text/javascript">
        window.onload = function() {

            $("#table1").show();
            $("#table2").hide();
            $("#table3").hide();
            $("#table4").hide();
        }
        $(document).ready(function() {
            $("#btn_1").click(function() {

                $("#table1").show();
                $("#table").hide();
                $("#table3").hide();
                $("#table4").hide();
            })
            $("#btn_2").click(function() {

                $("#table1").hide();
                $("#table2").show();
                $("#table3").hide();
                $("#table4").hide();
            })
            $("#btn_3").click(function() {

                $("#table1").hide();
                $("#table2").hide();
                $("#table3").show();
                $("#table4").hide();
            })
            $("#btn_4").click(function() {

                $("#table1").hide();
                $("#table2").hide();
                $("#table3").hide();
                $("#table4").show();
            })
        })
    </script>

<body>
    <div class="buttonbox">
        <button type="button" id="btn_1">tap1</button>
        <button type="button" id="btn_2">tap2</button>
        <button type="button" id="btn_3">tap3</button>
        <button type="button" id="btn_4">tap4</button>
    </div>
    <div style="clear:both;"></div>
    <div style="width : 480px; height: 400px;">
        <div id="table1" width="480px">
            <table class="col-100 col">
                <colgroup>
                    <col width="10%">
                    <col width="20%">
                    <col width="*%">
                    <col width="*%">
                </colgroup>
                <thead>
                    <tr>
                        <th>#</th>
                        <th>제품명</th>
                        <th>상세설명</th>
                        <th>가격</th>
                        <th>비고</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>
                            <div class="checkbox2 m-0">
                                <input id="checkbox0" type="checkbox">
                                <label for="checkbox0">
                                </label>
                            </div>
                        </td>
                        <td>1</td>
                        <td>~~~</td>
                        <td>100$</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td>
                            <div class="checkbox2 m-0">
                                <input id="checkbox0" type="checkbox">
                                <label for="checkbox0">
                                </label>
                            </div>
                        </td>
                        <td>2</td>
                        <td>~~~</td>
                        <td>100$</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td>
                            <div class="checkbox2 m-0">
                                <input id="checkbox0" type="checkbox">
                                <label for="checkbox0">
                                </label>
                            </div>
                        </td>
                        <td>3</td>
                        <td>~~~</td>
                        <td>100$</td>
                        <td>&nbsp;</td>
                    </tr>
                </tbody>
            </table>

        </div>

        <div id="table2" width="480px">
            <table class="col-100 col">
                <colgroup>
                    <col width="10%">
                    <col width="20%">
                    <col width="*%">
                    <col width="*%">
                </colgroup>
                <thead>
                    <tr>
                        <th>#</th>
                        <th>22</th>
                        <th>22</th>
                        <th>22</th>
                        <th>22</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>
                            <div class="checkbox2 m-0">
                                <input id="checkbox2" type="checkbox">
                                <label for="checkbox2">
                                </label>
                            </div>
                        </td>
                        <td>☆</td>
                        <td>☆</td>
                        <td>&nbsp;</td>
                        <td>☆</td>
                    </tr>
                    <tr>
                        <td>
                            <div class="checkbox2 m-0">
                                <input id="checkbox2" type="checkbox">
                                <label for="checkbox2">
                                </label>
                            </div>
                        </td>
                        <td>☆</td>
                        <td>☆</td>
                        <td>&nbsp;</td>
                        <td>☆</td>
                    </tr>
                    <tr>
                        <td>
                            <div class="checkbox2 m-0">
                                <input id="checkbox2" type="checkbox">
                                <label for="checkbox2">
                                </label>
                            </div>
                        </td>
                        <td>☆</td>
                        <td>☆</td>
                        <td>&nbsp;</td>
                        <td>☆</td>
                    </tr>
                    <tr>
                        <td>
                            <div class="checkbox2 m-0">
                                <input id="checkbox2" type="checkbox">
                                <label for="checkbox2">
                                </label>
                            </div>
                        </td>
                        <td>☆</td>
                        <td>☆</td>
                        <td>&nbsp;</td>
                        <td>☆</td>
                    </tr>
                    <tr>
                        <td>
                            <div class="checkbox2 m-0">
                                <input id="checkbox2" type="checkbox">
                                <label for="checkbox2">
                                </label>
                            </div>
                        </td>
                        <td>☆</td>
                        <td>☆</td>
                        <td>&nbsp;</td>
                        <td>☆</td>
                    </tr>
                </tbody>
            </table>
        </div>



        <div id="table3" width="480px">
            <table class="col-100 col">
                <colgroup>
                    <col width="10%">
                    <col width="20%">
                    <col width="*%">
                    <col width="*%">
                </colgroup>
                <thead>
                    <tr>
                        <th>3</th>
                        <th>3</th>
                        <th>3</th>
                        <th>3</th>
                        <th>3</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>
                            <div class="checkbox2 m-0">
                                <input id="checkbox1" type="checkbox">
                                <label for="checkbox1">
                                </label>
                            </div>
                        </td>
                        <td>♥</td>
                        <td>♥</td>
                        <td>♥</td>
                        <td>♥</td>
                    </tr>
                    <tr>
                        <td>
                            <div class="checkbox2 m-0">
                                <input id="checkbox1" type="checkbox">
                                <label for="checkbox1">
                                </label>
                            </div>
                        </td>
                        <td>♥</td>
                        <td>♥</td>
                        <td>♥</td>
                        <td>♥</td>
                    </tr>
                    <tr>
                        <td>
                            <div class="checkbox2 m-0">
                                <input id="checkbox1" type="checkbox">
                                <label for="checkbox1">
                                </label>
                            </div>
                        </td>
                        <td>♥</td>
                        <td>♥</td>
                        <td>♥</td>
                        <td>♥</td>
                    </tr>
                </tbody>
            </table>
        </div>



        <div id="table4" width="480px">
            <table class="col-100 col">
                <colgroup>
                    <col width="10%">
                    <col width="20%">
                    <col width="*%">
                    <col width="*%">
                </colgroup>
                <thead>
                    <tr>
                        <th>4</th>
                        <th>4</th>
                        <th>4</th>
                        <th>4</th>
                        <th>4</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>
                            <div class="checkbox2 m-0">
                                <input id="checkbox0" type="checkbox">
                                <label for="checkbox0">
                                </label>
                            </div>
                        </td>
                        <td>♤</td>
                        <td>♤</td>
                        <td>&nbsp;</td>
                        <td>%<br>%<br>%</td>
                    </tr>
                    <tr>
                        <td>
                            <div class="checkbox2 m-0">
                                <input id="checkbox0" type="checkbox">
                                <label for="checkbox0">
                                </label>
                            </div>
                        </td>
                        <td>♤</td>
                        <td>♤</td>
                        <td>&nbsp;</td>
                        <td>%<br>%<br>%</td>
                    </tr>
                    <tr>
                        <td>
                            <div class="checkbox2 m-0">
                                <input id="checkbox0" type="checkbox">
                                <label for="checkbox0">
                                </label>
                            </div>
                        </td>
                        <td>♤</td>
                        <td>♤</td>
                        <td>&nbsp;</td>
                        <td>%<br>%<br>%</td>
                    </tr>
                    <tr>
                        <td>
                            <div class="checkbox2 m-0">
                                <input id="checkbox0" type="checkbox">
                                <label for="checkbox0">
                                </label>
                            </div>
                        </td>
                        <td>♤</td>
                        <td>♤</td>
                        <td>&nbsp;</td>
                        <td>%<br>%<br>%</td>
                    </tr>
                    <tr>
                        <td>
                            <div class="checkbox2 m-0">
                                <input id="checkbox0" type="checkbox">
                                <label for="checkbox0">
                                </label>
                            </div>
                        </td>
                        <td>♤</td>
                        <td>♤</td>
                        <td>&nbsp;</td>
                        <td>%<br>%<br>%</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</body>
  @charset "UTF-8";

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body{
            margin-top: 100px;
            margin-left: 100px;
        }
        .col {
            border-collapse: collapse;
        }

        button {
            background-color: dodgerblue;
            padding: 8px 30px !important;
            width: 120px;
            font-size: 14px;
            color: white;
            border-top-left-radius: 20px;
            border-top-right-radius: 20px;
            border: 0px solid transparent;
            float: left;
        }

        button:hover {
            background-color: skyblue;
        }

        .col-100 {
            width: 100%;
        }

        table {
            text-align: center;
            font-size: 14px;
        }

        th {
            background-color: dimgrey;
            border: 1px solid rgba(224, 224, 224, 0.2);
            height: 34px;
            color: white;
            font-size: 12px;
        }

        tr,
        td {
            padding: 4px 0px;
            border: 1px solid rgba(224, 224, 224, 0.2);
            font-size: 12px;
        }

 

 

반응형