使用: Node.prototype.previousSbling
用法和 Node.prototype.nextSbling 相同.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <div id="id1">李雷</div><div id="id2">韩梅梅</div> <script> document.getElementById('id2').previousSibling === document.getElementById('id1'); // true document.getElementById('id2').previousSibling.firstChild.nodeValue; // 李雷 </script> </body> </html>