jQuery | javascript | CSS

16.jQuery - hover 메서드 ( 16.hover )

Godffs 2009. 11. 6. 12:12
반응형

- hover( over, out )을 지원하는 메서드
hover()로 마우스오버와 아웃을 동시 처리하는 예제입니다.

16.Hover.htm

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

<head>

    <title>hover() 마우스오버와 아웃을 동시 처리</title>

    <style type="text/css">

        .hover

        {

            cursor: hand;

            background-color: Yellow;

        }

    </style>

 

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

 

    <script type="text/javascript">

        $(document).ready(function() {

            $('table tr:gt(0)').hover(function() { $(this).addClass('hover'); },

             function() { $(this).removeClass('hover'); });

            $('table tr').slice(1, 3).addClass('hover');

        });

        //'table tr:gt(0) 0보다 큰것만 마우스 오버 효과가 나타남

    </script>

 

</head>

<body>

    <table border="1">

        <tr>

            <td>제목</td>

        </tr>

        <tr>

            <td>ASP.NET</td>

        </tr>

        <tr>

            <td>Silverlight</td>

        </tr>

    </table>

</body>

</html>


결과화면

[그림16-1]
16.Hover.htm
반응형