Get elements and onmousemove events directly through document (the picture moves with the mouse)

1. Get elements directly through document

    < script > 
    // 1. Get body 
    console.log(document.body); // Return body tag (element) 
    // 2. Get title 
    console.log(document.title); // Return the value in the tag, ie Title 
    // 3. Get html 
    console.log(document.documentElement); // return html tag (element) 
    </ script >

Two, onmousemove event

<!-- //4. Case: The picture moves with the mouse --> 
    < img src ="1.png" alt ="" id ="im" style ="position: absolute;" > 
    < script > 
        document.onmousemove = function (e){
             // The abscissa and ordinate of the mouse movement 
            // the abscissa of the visible area 
            // the ordinate of the visible area 
            document.getElementById( " im " ).style.left = e.clientX + 15 + " px " ;
            document.getElementById("im").style.top=e.clientY+"px";
        };
    </script>

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325424114&siteId=291194637