Manipulation - 특정 용어에 대해서 번호 붙이기
.NET프로그래밍/jQuery 1.3.2 2009. 11. 11. 10:09 |
[Append.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() {
//[1] term CSS 클래스에 배경색 적용
$('.term')
.not(":odd").css("backgroundColor", "Yellow")
.end()
.filter(":odd").css("background-color", "LightBlue");
//[2] 각각의 주석/용어 뒤에 번호 붙이기
$('.term').each(function(i) { $(this).append("<sup>" + (i + 1) + "</sup>"); });
});
</script>
</head>
<body>
<h3>jQuery is a new kind of JavaScript Library.</h3>
<div>
<span class="term">jQuery</span> is a fast and concise <span class="term">JavaScript</span> Library
that simplifies <span class="term">HTML</span> document traversing,
event handling, animating, and <span class="term">Ajax</span> interactions
for rapid web development.
jQuery is designed to change the way that you write JavaScript.
</div>
</body>
</html>
-------------------------------------------------------------------------------------
[실행결과]
'.NET프로그래밍 > jQuery 1.3.2' 카테고리의 다른 글
Manipulation - Clone() 메서드 (검색된 요소를 복사하기) (0) | 2009.11.11 |
---|---|
Manipulation - Wrap()메서드 (검색된 요소를 특정 태그로 감싸기) (0) | 2009.11.11 |
Manipulation - DOM 요소의 앞/뒤에 요소 추가 (0) | 2009.11.11 |
Manipulation - Append() 메서드 (DOM 요소 생성 후 원하는 요소에 추가) (0) | 2009.11.11 |
Traversing - 방금 실행한 집합 이전으로 되돌리기 (0) | 2009.11.10 |