[Attr.htm]

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

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

<head>

    <title>DOM요소의 attribute 읽어오기</title>

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

    <script type="text/javascript">

        $(document).ready(function() {

            //[1] get

            alert($('a').attr('href')); // get

 

            //[2] set : img에 마우스 오버시 이미지 변경

            $('img:first').mouseover(function() {

                $(this).attr("src",

                    "http://www.dotnetkorea.com/Website/Portals/0/dotnetkorealogo.gif");

            });

 

            //[3] 마우스오버/아웃시 다른 이미지 표시

            $('#copy').mouseover(function () {

                $(this).attr('src', "../images/icon_copy_over.gif");

            });

            $('#copy').mouseout(function () {

                $(this).attr('src', "../images/icon_copy.gif");

            });

        });

    </script>

</head>

<body>

 

<a href="http://www.dotnetkorea.com/">닷넷코리아</a>

 

<img src="images/logo.jpg" alt="닷넷코리아로고" />

 

<img src="../images/icon_copy.gif" id="copy" />

 

</body>

</html>




-------------------------------------------------------------------------------------




[실행결과]

--> 첫 화면.





--> 위의 그림에서 메시지박스의 '확인'버튼을 누른 후, 위의 그림의 "닷넷코리아로고"텍스트에 '마우스오버(mouseover)'시에 아래그림에서 해당 이미지가 출력된 화면.




--> 바로 위의 그림에서 맨 오른쪽에 있는 작은이미지에 '마우스오버(mouseover)'했을때 화면.




--> 바로 위의 그림에서 맨 오른쪽에 있는 작은이미지에서 '마우스아웃(mouseout)'했을때 화면.



Posted by holland14
: