html, head, meta, title, body, p 등의 태그는 object type 형식을 띄고 있다.
javascript로 특정 p태그에 접근해보기
앞서 배웠듯이
document.querySelectorAll("p") 에서 document는 뒤에 .이 있기에 object type,
document.querySelectorAll은 뒤에 ()이 오기에 function type인 것을 알 수 있다.
이후 NodeList(5) [p, p, p, p, p] 정보에 []를 보면 document.querySelectorAll("p")은 array type이다.
이후 출력되는 값이 p태그 이기 때문에 object type 뒤에 작성하는 .을 입력하고 innerText를 통해 해당 string type 문자를 출력한다.
접근을 완료한 뒤에는 변경을 해본다. 필자는 "김구라", 1, document.querySelectorAll("p")[1].innerText를 시도해봤다.
'javascript, framework > javascript' 카테고리의 다른 글
Step01_example2,3 (inner Text, value 변경, Number()) (0) | 2022.07.06 |
---|---|
Step01_example1 2 (querySelector) (0) | 2022.07.06 |
Step01_dataType11 (confirm, prompt, if ) (0) | 2022.07.06 |
Step01_dataType10 2 (type 복습, 참조 데이터) (0) | 2022.07.06 |
Step01_dataType10 (매개 변수, 연결연산) (0) | 2022.07.05 |