2021 10 27 오전 : javascript - 네이버 뉴스스탠드
html / javascript
html : 처음부터 아래로 순차적으로 실행...
1. <!doctype html> => 웹 브라우저 엔진 : html5 엔진 / html4 엔진
2. <html
3. <head
4. <meta charset="utf-8">
5. <title>~~~</title>
6. <link ~~~ >
7. <script>
function init(){
8. var table=document.querySelector("#tbl"); // <= null
table.innerHTML = 태그들.... // <= null.innerHTML = 태그들,,...
}
</script>
</head>
<body onload="init()">
<table id="tbl"></table>
</body>
</html>
이벤트 : onload (이벤트가 설정된 태그가 모두 로드가 끝나면 지정한 함수를 호출하는 이벤트)
onclick (이벤트가 설정된 태그를 사용자가 마우스 왼쪽 버튼을 눌렀다가 해당 태그 위에서 떼었을 때 지정한 함수를 호 출하는 이벤트)
배열 : [ ] 을 이용하여 선언
: 데이터의 갯수 (length)
객체 : Object => 선언 : 1. var o = new Object();
o.num=10;
o.name = "이름";
2. var o2 = {키 : 값, 키 : 값, .... };
var o3 = { num:10, name:"이름" };
뉴스 스탠드 관련
var newsStandArr=[
{n:"경향신문", img:"nsd16500796.gif", u:"http://newsstand.naver.com/032", k:"종합지"},
:
:
]
newsStandArr 데이터의 총 갯수 : newsStandArr.length
newsStandArr 데이터 추출 : newsStandArr[index]
newsStandArr 내의 index를 이용하여 실제 데이터 추출 : newsStandArr[index].변수명
=> newsStandArr[0].img => "nsd16500796.gif"
newsStandArr[0].u => "http://newsstand.naver.com/032"
<table> 내부에서 4번
<tb>:<tr> 1회 <td> 총 6회
newsStandArr.length => 95 => 0, ~~~~ 94
=> 4행 6열 (index no : 0, ~~23)
var count=0;
for(var i=0; i<4; i++ ){ // i => 0, 1, 2, 3
<tr>
for(var k=0; k<6; k++){ // k => 0, 1, 2, 3, 4, 5 / 0, 1, 2, 3, 4, 5 / 0, 1, 2, 3, 4, 5 / 0, 1, 2, 3, 4, 5
<td>
<a href=newsStandArr[count].u>
<img src=newsStandArr[count].img />
</a>
</td>
count++ ; // 1 => 2
}
</tr>
}
document.querySelector("#tbl").innerHTML="~~~";
<table>
<tr>
<td>
<a href="newsStandArr[0].u">
<img src="./newsImages/" + newsStandArr[0].img />
</a>
</td>
5번 더 사용
</tr>
</table>
전체문자열.includes(부분문자열)
var t1 = "hello";
var t2 = "he";
t1.includes(t2) => 포함하고 있으면 : TRUE / FALSE
자바
public class Test{
public String s1="test";
public void sample(){
String local="test";
}
}
자바스크립트
<script>
var t="www";
var local;
function test(){
var local=t;
}
function test2(){
local=t;
}
</script>
'IT > Web' 카테고리의 다른 글
【web기본】2021 10 28 : eclipse Encoding 변경 (0) | 2022.03.31 |
---|---|
【web기본】2021 10 27 : Servlet & JSP (0) | 2022.03.31 |
【web기본】2021 10 26 : Javascript에 대하여 (0) | 2022.03.31 |
【web기본】2021 10 26 : CSS 에 대하여 (0) | 2022.03.31 |
【web기본】2021 10 25 -HTML (0) | 2022.03.31 |