<body>
<div id='practice' class='highlight red'>
여기 엘리먼트가 하나 있습니다
<span>자식도 하나 있습니다</span>
<span>자식도 여럿 있습니다</span>
</div>
</body>
JavaScript를 이용해서 엘리먼트의 속성값을 얻어내거나, 변경하는 법.
트리구조의 html을 JS 객체형태로 바꾸어보면!
위의 html 문서의 구조&관계를 객체(obj)로 표현한 모델.
마찬가지로 트리구조
document라는 "전역변수"로 접근이 가능해진다!!!!!!!!! (recursion 과제 때 꼭 알아야했던 개념!)
DOM은 절대 JS는 아니지만 그저 JS를 이용해서 dom 구조에 접근 할 뿐??
i.e. "document.~"이런 방식으로 접근했었다. future-me will elaborate on this.
{
tagName: 'DIV',
id: 'practice',
classList: ['highlight', 'red'],
textContent: '여기 엘리먼트가 하나 있습니다 자식도 있습니다 자식도 여럿 있습니다',
parentElement: body,
children: [
{
tagName: 'SPAN',
textContent: '자식도 있습니다'
},
{
tagName: 'SPAN',
textContent: '자식도 여럿 있습니다'
}
]
}
1. class list가 띄어쓰기로 두 개로 분리가 가능하다? 잘못 본건가.
'JavaScriptVeryBeiginning' 카테고리의 다른 글
프리코스 4주 회고 (0) | 2020.07.20 |
---|---|
조건문 쓰기 (성적에 대한) (0) | 2020.07.11 |
HTML opening default (0) | 2020.07.01 |
What's the difference between return and console.log? (0) | 2020.06.27 |
Using let keyword in relation to reassignment and scope pollution (0) | 2020.06.20 |