Javascript _ javascript tips

Source: Internet
Author: User
This article mainly introduces how js implements multiple gradient effects on the same page. It involves the implementation skills of javascript operations on gradient effects, which is of great practical value, for more information about how to implement multiple gradient effects on the same page in js, see the following example. Share it with you for your reference. The specific analysis is as follows:

Here we can achieve one of the five elements, move the mouse up the transparency gradually increases, move the mouse out, the transparency gradually decreases.

Key Aspect 1:

var speed = 0;if(target>obj.alpha){speed = 5;}else{speed = -5;}

Based on the comparison between the target value and the current value, it is determined whether the speed is positive or negative.

Key Aspect 2:

For (I = 0; I
 
  

Each element is added with its own transparency value, and their respective transparency changes are separated.

Finally, run the following code:

   Untitled documentScript window. onload = function () {var runs = document. getElementById ("runs"); var runs_li = runs. getElementsByTagName ("li"); var I = 0; for (I = 0; I
   
    
Obj. alpha) {speed = 5;} else {speed =-5;} if (obj. alpha = target) {clearInterval (obj. timer);} else {obj. alpha = obj. alpha + speed; obj. style. filter = "alpha (opacity =" + obj. alpha + ")"; obj. style. opacity = obj. alpha/100 ;}}, 30)} script
    
  
  • 1
  • 2
  • 3
  • 4
  • 5

I hope this article will help you design javascript programs.

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.