02.jQueryIndexer.htm |
<html xmlns="http://www.w3.org/1999/xhtml"> <head>
<title>HTML 요소 가져오기</title>
<script src="../jQuery/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function()
{ //h3 요소 모두 가져오기 var
headers = $('h3'); // 반복문을 써서 반복 : for문보다는 jQuery의 each문이 사용하기 편리 for
(var i = 0; i < headers.length; i++) { alert($(headers[i]).html()); } /* //위 코드를 each문으로 변경 $('h3').each(function(index) { alert($(this).html()); }); */
});
</script> </head> <body>
<h3>준철이</h3>
<h3>멋있다</h3> </body> </html> |
결과화면 |
[그림22-1] |
'jQuery | javascript | CSS' 카테고리의 다른 글
24.jQuery - 속성값 복사 ( 02.Selectors - 02.Text ) (0) | 2009.11.09 |
---|---|
23.jQuery - Input ( 02.Selectors - 01.Input ) (0) | 2009.11.09 |
21.jQuery - Each() 메서드 ( 01.Core-01.Each ) (0) | 2009.11.09 |
-- 현재 까지의 jQuery 소스 -- (0) | 2009.11.09 |
20.jQuery - CallBack ( 20.CallBack ) (0) | 2009.11.09 |
Comments