document.querySelector('.guess').value = ''
document.querySelector('.guess').textContent = ''
- Only input elements have a "value". It represent the input data supplied by the user or provided initially by the code. Whereas textContent property sets or returns the text content of the specified node, and all its descendants.
- 오직 Input elements만 value를 가진다. 다른 elements는 textContent로 수정하면 된다!
- textContent returns the concatenation of the textContent of every child node, excluding comments and processing instructions and if if the node has no children then textContent will be empty string.
value를 가진 elem은 'input' data type밖에 없다. 여기서 'class = guess'가 input 데이터타입이었음.
'자바스크립트' 카테고리의 다른 글
[JavaScript] HTML structure 자동 설정 (vs code) (0) | 2020.12.04 |
---|---|
[JavaScript] function, function() 차이 (0) | 2020.12.04 |
[JavaScript] 55. Setting up prettier and VS code (console.log 단축키) (0) | 2020.12.04 |
[JavaScript] 40. Basic Array Operations(Methods) (0) | 2020.12.04 |
[JavaScript] udemy - the complete javascript course를 들으며 기록합니다. (0) | 2020.12.04 |