ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

JS

DOM ๊ฐ์ฒด 02

๐Ÿ”ฅ fire 2010. 7. 9. 21:42

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>ํƒœ๊ทธ๋ช…์œผ๋กœ ์š”์†Œ๊ฒ€์ƒ‰</title>
<script type="text/javascript">
 window.onload = function() {
  //pํƒœ๊ทธ๋ฅผ ๊ฒ€์ƒ‰ํ•œ๋‹ค.
  var pList = document.getElementsByTagName("p");

  //์ˆœ์ฐจ์ ์œผ๋กœ ์ธ๋ฑ์Šค๋กœ ๊ฐ๊ฐ์˜ p๋ฅผ ์ฐพ๋Š”๋‹ค.
  for(i =0 ; i < pList.length; i++) {
   //pํƒœ๊ทธ์˜ ์ฒซ์งธ ์ž์‹ ๋…ธ๋“œ๋Š” ํ…์ŠคํŠธ ๋…ธ๋“œ์ด๋‹ˆ๊นŒ.
   var txt = pList[i].childNodes[0].nodeValue;
   view.innerHTML += txt + "<br/>";
  }
 }
</script>

<style type="text/css">
 #view {
  float: right;
  width: 300px;
  height: 500px;
  border: 1px solid black;
  overflow: auto;
 }
</style>
</head>
<body>

 <h2>ํƒœ๊ทธ๋ช…์œผ๋กœ ์š”์†Œ ๊ฒ€์ƒ‰</h2>
 <div id="view"></div>
 <p>'์ง„์‹ค๊ฒŒ์ž„'์ด CCTV ๊ณต๊ฐœ๋ฅผ ํ†ตํ•ด ์‚ฌ์‹ค๋กœ ๋“œ๋Ÿฌ๋‚ฌ๋‹ค.</p>
 <p>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</p>
 <p>bbbbbb</p>
 <p>ccccccccccc</p>
 <p>1111111111111</p>

</body>
</html>

'JS' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

Ajax ์‹œ์ž‘_์ฒ˜๋ฆฌํŽ˜์ด์ง€  (0) 2010.07.12
Ajax ์‹œ์ž‘  (0) 2010.07.12
DOM ๊ฐ์ฒด 01  (0) 2010.07.09
JSON ์ด์šฉํ•œ ๊ฐ์ฒด toString  (0) 2010.07.09
JSON ์ด์šฉํ•œ ๊ฐ์ฒด์ƒ์„ฑ  (0) 2010.07.09
๋Œ“๊ธ€