CLI 환경에서 JS 실행하기
NodeJS 패키지 설치
sudo apt install nodejs
nodejs 버젼 확인하기
node --version
js 파일 실행하기
node js파일이름.js
DOM_innerHTML / innerText
var 변수 = document.getElementById("id명");
.innerHTML - id로 지정된 것의 html 내용이 그대로 나옵니다.
.innerText - id로 지정된 것의 Text만 출력됩니다.
Attribute 속성 조작
var 변수 = document.getElementById("id명");
변수.getAttribute("속성");
변수.setAttribute("속성","바꾸고 싶은 값");
변수.getAttribute(”속성”); → 속성값 가져오기변수.setAttribute(”속성”,”바꾸고 싶은 값”); → 속성값 변경하기변수 접근의 여러가지 방법
document.getElementById("아이디명");document.getElementByClassName(”클래스명”);document.getElementByName("이름명");document.getElementByTagName("태그명")위에 더해서 getElements 뒤에 “s"를 붙인 다면 여러개를 한번에 접근할 수 있음
이벤트 추가하기