jQuery | javascript | CSS

08.jQuery - Bind 메서드 ( 08.Bind )

Godffs 2009. 11. 6. 09:33
반응형

bind(eventType, data, listener) 메서드
- 이벤트 바인딩 할당을 위한 API


08.Bind.htm

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

<head>

    <title>bind() 메서드로 동적으로 이벤트 부여</title>

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

    <script type="text/javascript">

        $(document).ready(function() {

 

            $('#btnClick').bind("click", function() { alert("클릭됨"); });

           

            $('#btnClick').bind('mouseover', function() {

                document.getElementById('btnClick').style.backgroundColor = 'red';

            });

           

            $('#btnClick').bind("mouseout", function() {

                $('#btnClick').get(0).style.backgroundColor = '';

            });

           

        });

    </script>   

</head>

<body>

 

        <div id="btnClick">

                 클릭하세요!!!

                

</div>

</body>

</html>


결과화면

[그림8-1]

추가 설명
[그림8-2]
08.Bind.htm
반응형