Manipulation - Wrap()메서드 (검색된 요소를 특정 태그로 감싸기)
.NET프로그래밍/jQuery 1.3.2 2009. 11. 11. 10:33 |
[Wrap.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>검색된 요소를 특정 태그로 감싸기(Wrap)</title>
<script src="../js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
//[1] <h3>...</h3>을 <u>태그로 묶자
$('h3').wrap("<u></u>");
//[2] 모든 A 태그를 <li>으로 묶자.
//[a] 첫번째 링크앞에 동적으로 <ol> 태그 삽입
$('<ol type="1" id="community"></ol>').insertBefore('a:eq(0)');
//[b] 모든 링크를 <li>로 감싸고 이를 <ol> 태그에 추가
$('a').each(function() {
$(this).appendTo('#community').wrap('<li></li>');
});
});
</script>
</head>
<body>
<h3>.NET 기술 관련 커뮤니티</h3>
<a href="http://www.asp.net/">ASP.NET</a>
<a href="http://www.silverlight.net/">Silverlight</a>
<a href="http://www.windowsclient.net/">WPF</a>
<a href="http://www.dotnetkorea.com/">.NET All(?)</a>
</body>
</html>
-------------------------------------------------------------------------------------
[실행결과]
--> 여기서는 '파이어폭스' 브라우저에서 출력되지 않는 결과가 발생해서, "Internet Explorer"를 기본 브라우저로 설정후 '브라우저에서 보기'로 실행하였다.
'.NET프로그래밍 > jQuery 1.3.2' 카테고리의 다른 글
Manipulation - ReplaceWith() 메서드 (검색된 요소를 변경하기) (0) | 2009.11.11 |
---|---|
Manipulation - Clone() 메서드 (검색된 요소를 복사하기) (0) | 2009.11.11 |
Manipulation - 특정 용어에 대해서 번호 붙이기 (0) | 2009.11.11 |
Manipulation - DOM 요소의 앞/뒤에 요소 추가 (0) | 2009.11.11 |
Manipulation - Append() 메서드 (DOM 요소 생성 후 원하는 요소에 추가) (0) | 2009.11.11 |