Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setAttribute #21

Closed
dooly9 opened this issue Mar 27, 2017 · 1 comment
Closed

setAttribute #21

dooly9 opened this issue Mar 27, 2017 · 1 comment

Comments

@dooly9
Copy link

dooly9 commented Mar 27, 2017

list.setAttribute('style', 'display: none');

이것과

list.style.display='none'

둘다 dom api 인가요?
그리고 저둘은 차이 없죠?

p.s 수업때 말씀드린 innerText와 textContent 차이 부탁합니다.

@yamoo9
Copy link
Owner

yamoo9 commented Mar 27, 2017

XML DOM vs HTML DOM

DOM 방식의 차이 입니다.

XML DOM.xml, .html, .htm 모두 사용 가능하지만,

list.setAttribute('style', 'display: none')

HTML DOM.xml에서는 사용할 수 없습니다.

list.style.display='none'

textContent VS innerText

textContent와 innerText의 차이점은 다음과 같습니다.

  • textContent는 HTML 텍스트 코드를 단순히 텍스트로 출력한다.
  • textContent는 모든 요소의 내용을 가져올 수 있다. 반면 innerText는 그렇지 않다.
  • innerTexttextContent와 달리 숨겨진 요소들의 텍스트는 반환하지 않는다.
  • textContent 속성은 IE 9+ 지원되지만, innerText는 모든 브라우저에서 지원된다.

@yamoo9 yamoo9 closed this as completed Mar 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants