Javascript implementation simple mouse follow DiV layer effect complete example _ javascript tips-JS tutorial

Source: Internet
Author: User
This article mainly introduces the simple implementation of JavaScript with the mouse following the DiV layer, and involves related techniques for JavaScript to dynamically operate page element Attributes Based on Time functions. It has some reference value, if you need it, refer to the example in this article to describe how JavaScript achieves the simple Effect of following the DiV layer with the mouse. We will share this with you for your reference. The details are as follows:

This Code presents a string of Div effects that follow the mouse, and has the drag and drop effects. As the mouse rapidly shakes, The Div Layer Effect will continuously increase and the following Div will automatically disappear, however, there are still some bugs. We look forward to working with you to improve this JS special effect.

The running effect is as follows:

The Online Demo address is as follows:

Http://demo.jb51.net/js/2015/js-simple-mouse-over-p-codes/

The Code is as follows:

 Div effect following the mouseScript window. onload = function () {var aDiv = document. getElementsByTagName ('P'); var I = 0; setInterval (function () {for (I = aDiv. length-1; I> 0; I --) {aDiv [I]. style. left = aDiv [I-1]. style. left; aDiv [I]. style. top = aDiv [I-1]. style. top ;}}, 5); document. onmousemove = function (ev) {var oEvent = ev | event; aDiv [0]. style. left = oEvent. clientX + 'px '; aDiv [0]. style. top = oEvent. clientY + 'px ';};}; 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.