Attributes - 특정 속성을 지우기
.NET프로그래밍/jQuery 1.3.2 2009. 11. 10. 10:01 |
[RemoveAttr.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>특정 속성을 지우기</title>
<script src="../js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
// 버튼 클릭시 특성/속성/attribute/어트리뷰트/애트리뷰트 제거
$('#btnRemove').click(function() {
$('img:first').removeAttr("src"); // src 속성 삭제
});
});
</script>
</head>
<body>
<input type="button" id="btnRemove" value="src삭제" />
<img src="../ProductImages/thumbs/HARDWARE-01.jpg" alt="하드웨어" />
<img src="../ProductImages/thumbs/HARDWARE-01.jpg" alt="하드웨어" />
</body>
</html>
-------------------------------------------------------------------------------------
[실행결과]
--> 첫 화면.
--> 위의 그림에서 'src삭제'버튼을 클릭하면 버튼 바로 옆에 있는 첫번째 이미지가 삭제되면서 ,"하드웨어"라는 대체 텍스트로 아래그림과 같이 출력된다.
'.NET프로그래밍 > jQuery 1.3.2' 카테고리의 다른 글
Attributes - 폼 요소의 값 가져오기 및 설정 (0) | 2009.11.10 |
---|---|
Attributes - 텍스트 값 가져오기 및 설정 (0) | 2009.11.10 |
Attributes - 맵(컬렉션)으로 다중 속성 지정 (0) | 2009.11.10 |
Attributes - 마우스 오버시 큰 이미지 보여주기 (1) | 2009.11.10 |
Attributes - DOM요소의 attribute 읽어오기 (0) | 2009.11.09 |