- JQuery 특정 태그 선택 : find()
<!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>
<script src="http://code.jquery.com/jquery-1.7.min.js"></script>
<script>
//변수 선언
var xml = "";
xml += "<friends>";
xml += " <friend>";
xml += " <name>연하진</name>";
xml += " <language>Ruby</language>";
xml += " </friend>";
xml += " <friend>";
xml += " <name>윤명월</name>";
xml += " <language>Basic</language>";
xml += " </friend>";
xml += " <friend>";
xml += " <name>윤하린</name>";
xml += " <language>C#</language>";
xml += " </friend>";
xml += "</friends>";
$.noConflict();
var J = jQuery;
J(function () {
var xmlDoc = J.parseXML(xml);
J(xmlDoc).find("friend").each(function () {
var outPut = "";
outPut += "<div>";
outPut += " <h1>" + J(this).find("name").text() + "</h1>";
outPut += " <p>" + J(this).find("language").text() + "</p>";
outPut += "</div>";
document.body.innerHTML += outPut;
});
});
</script>
<title>Untitled Page</title>
</head>
<body>
</body>
</html>
'공부 > JQuery' 카테고리의 다른 글
JQery_[ hover() & toggle ] (0) | 2013.01.21 |
---|---|
JQuery_[ 이벤트 연결 기본 bind() ] (0) | 2013.01.21 |
JQuery_[JQuery filter() 메서드 사용] (0) | 2013.01.07 |
JQuery_[JQuery 를 이용한 객체 확장] (0) | 2013.01.07 |
JQuery_[배열1(스크립트배열), 배열2(선택자)] (0) | 2013.01.07 |