2023-07-20T15:14:22.png

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        td{
            width:100px;
            height:40px;
        }

    </style>
</head>
<body>


    <div id="box">
        <p>这是段落1</p>
        <p>这是段落2</p>
        <p id="p3">这是段落3</p>
        <p>这是段落4</p>
        <p>这是段落5</p>
    </div>



    


<script>
function my$(id){return document.getElementById(id)};

var p3 = my$("p3");

console.log(p3.previousSibling);

console.log(p3.nextSibling);

console.log(p3.previousElementSibling);

console.log(p3.nextElementSibling);










</script>


</body>
</html>