JavaScript
-
210923_getElementById,window.onloadJavaScript 2021. 9. 23. 11:43
getElementById DOCTYPE html> Insert title here //스크립트에서 html의 dom객체에 접근하려면 id 이용 document.getElementById('name'); //head태그에선 접근은 가능하나 변경 못함..body태그에서는 가능 document.getElementById('name').innerHTML='이길동'; //innerHTML: html의 내부요소 홍길동 window.onload DOCTYPE html> Insert title here //스크립트에서 html의 dom객체에 접근하려면 id 이용 window.onload=function(){ //html의 로딩이 끝나야 시작..페이지의 모든 요소가 로드되어야 호출 document.getElementB..
-
210923_전역변수,지역변수JavaScript 2021. 9. 23. 11:11
DOCTYPE html> Insert title here //전역변수 var a=10; var b=100; function outer() { //지역변수 var a=20; document.write("3.outer a="+a+" "); document.write("4.outer b="+b+" "); } //전역변수 호출 document.write("1.a="+a+" "); document.write("2.b="+b+" "); //outer 호출 outer();