https://www.w3schools.com/jsref/prop_node_previoussibling.asp
HTML DOM previousSibling Property
HTML DOM previousSibling Property Element Object Example Get the HTML content of the previous sibling of a list item: var x = document.getElementById("item2").previousSibling.innerHTML; The result of x will be: Coffee (first li) --> Try it Yourself » Defin
www.w3schools.com
https://www.w3schools.com/jsref/prop_element_previouselementsibling.asp
HTML DOM previousElementSibling Property
HTML DOM previousElementSibling Property Element Object Example Get the HTML content of the previous sibling of a list item: var x = document.getElementById("item2").previousElementSibling.innerHTML; The result of x will be: Coffee (first li) --> Try it Yo
www.w3schools.com


previousSibling() > Element는 물론 #text와 주석까지 node로 카운트하여 반환
previousElementSibling() > Element만 카운트하여 반환
previousSibling / previousElementSibling
nextSibling / nextElementSibling
parentNode / parentElement
childNodes / children
'CSS&JS > 👀Study and Copy' 카테고리의 다른 글
$(this).index(); 를 vanilla JS로 대체하기 (indexOf) (0) | 2020.01.28 |
---|---|
vanilla JS로 prevAll, nextAll 대체 (0) | 2020.01.28 |
$(document).ready(function(){}); vanilla JS로 대체 DOMContentLoaded (0) | 2020.01.23 |
JS 자바스크립트 .children과 .childNodes의 차이 (0) | 2020.01.21 |
비쥬얼 스튜디오 코드(VS Code) 기본 세팅 확장프로그램 및 설정 // 자주쓰는 단축키 메모 (0) | 2019.12.19 |