This article mainly introduces the Javascript implementation of the mouse following code, with a cartoon hand click effect. it involves JavaScript mouse event response and dynamic calling of page elements. For more information, see the following example. We will share this with you for your reference. The details are as follows:
The effect of a small hand following the mouse, where the mouse moves, where the small hand moves, the effect of the hand will appear, when placed on the link, the hand will change, the two hands are cute. Share the Code with you with the JS mouse.
The running effect is as follows:
The Online Demo address is as follows:
Http://demo.jb51.net/js/2015/js-handle-style-focus-codes/
The Code is as follows:
Cute mouse followScript window. onload = function () {var oCursor = document. getElementById ("cursor"); document. onmousemove = function (ev) {var oEvent = ev | event, oWidth = document.doc umentElement. clientWidth, oHeight = document.doc umentElement. clientHeight, scrollTop=document.doc umentElement. scrollTop + oEvent. clientY, scrollleft;document.doc umentElement. scrollLeft + oEvent. clientX; if (scrollTop> oHeight-oCursor.offsetHeight) {oCursor. style. top = oHeight-oCursor.offsetHeight + 'px ';} else if (scrollTop <0) {oCursor. style. top = 0;} else {oCursor. style. top = scrollTop + 'px ';} if (scrollLeft> oWidth-oCursor.offsetWidth) {oCursor. style. left = oWidth-oCursor.offsetWidth + 'px ';} else {oCursor. style. left = scrollLeft + 'px ';} document. onmousedown = function () {oCursor. innerHTML = ""; return false;} document. onmouseup = function () {oCursor. innerHTML = "" ;}};} script
I hope this article will help you design JavaScript programs.