Javascript-implemented mouse-followed code (cartoon hand-clicked effect) _ javascript skills

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.