标签:inner previous element selector div next nts class java
const app = document.getElementById(‘app‘); app.innerHTML = ` <h1>JavaScript DOM</h1> <ul id="list"> <li>1</li> <li>2</li> <li>3</li> <li>4</li> </ul> `; const listItem = document.querySelector(‘#list li‘); // Any DOM Nodes console.log(listItem.nextSibling); console.log(listItem.previousSibling); // Any Element Nodes console.log(listItem.nextElementSibling); console.log(listItem.previousElementSibling);
[Javascript] Finding Sibling Elements
标签:inner previous element selector div next nts class java
原文地址:https://www.cnblogs.com/Answer1215/p/12596292.html