Attributes - DOM요소의 attribute 읽어오기
.NET프로그래밍/jQuery 1.3.2 2009. 11. 9. 12:27 |
[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)'했을때 화면.
'.NET프로그래밍 > jQuery 1.3.2' 카테고리의 다른 글
Attributes - 맵(컬렉션)으로 다중 속성 지정 (0) | 2009.11.10 |
---|---|
Attributes - 마우스 오버시 큰 이미지 보여주기 (1) | 2009.11.10 |
Form관련 jQuery 선택기 명령어 - :selected (드롭다운리스트에서 선택한 값 가져오기) (0) | 2009.11.09 |
Form관련 jQuery 선택기 명령어 - 암호확인(PasswordConfirm) 기능 구현하기 (0) | 2009.11.09 |
Form관련 jQuery 선택기 명령어 - :text (텍스트박스의 값 복사) (0) | 2009.11.09 |