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>