Blog Content

    티스토리 뷰

    82.jQuery - TablePlugIn (13.Sample )

    반응형
    배경색 변경을 jQuery 플러그인으로 업그레이드 한 예제입니다.

    TablePlugIn.htm

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

        <title>짝수행과홀수행의 배경색 변경 플러그인</title>

        <style type="text/css">

            .odd{ background-color:Silver;}

            .even{ background-color:Aqua;}

        </style>

       

        <script src="jQuery/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>

        <script type="text/javascript">

       

            $.fn.alternateRowColors = function () {

                $('tbodytr:odd', this).removeClass('even').addClass('odd');

                $('tbodytr:even', this).removeClass('odd').addClass('even');

                returnthis;

            };

           

            $(document).ready(function () {

                $('table.tbl').each(function () {

                    var$table = $(this);

                    // 플러그인 호출                   

                    $table.alternateRowColors();

                });               

            });

        </script>

    </head>

    <body>

        <table class="tbl" border="1">

            <thead>

                <tr>

                    <th>&nbsp;</th>

                    <th>제목</th>

                    <th>직업</th>

                    <th>이름</th>

                    <th>비고</th>

                </tr>

            </thead>

            <tbody align="center">

                <tr>

                    <td><img src="img/j1.jpg" /></td>

                    <td>완전좋앙</td>

                    <td>텔런트</td>

                    <td>조선옥</td>

                    <td>너무좋앙</td>

                </tr>

                <tr>

                    <td><img src="img/j2.jpg" /></td>

                    <td>완전좋앙</td>

                    <td>텔런트</td>

                    <td>조선옥</td>

                    <td>완전이뻐!</td>

                </tr>

                <tr>

                    <td><img src="img/j3.jpg" /></td>

                    <td>완전좋앙</td>

                    <td>텔런트</td>

                    <td>조선옥</td>

                    <td>내이상형!!</td>

                </tr>

                <tr>

                    <td colspan="5">/짝배경색이 같아요</td>

                </tr>

                <tr>

                    <td colspan="5">/짝배경색이 같아요</td>

                </tr>

                <tr>

                    <td colspan="5">/짝배경색이 같아요</td>

                </tr>

            </tbody>

        </table>

    </body>

    </html>


    결과화면

    [그림82-1]



    반응형

    Comments