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
I hope this article will help you design javascript programs.