This article mainly introduces the js focus text rolling effect, which is very simple to implement and is recommended to everyone. If you need it, you can refer to it. This article describes the js focus text rolling effect. Share it with you for your reference. The details are as follows:
Effect description:
This is a native js focus chart recommended today.
Automatic Switch by default, or manual switch
Javascript Code adopts function-based object programming, that is, the Module mode in javascript programming.
The basic usage is simple,
There are three main features::
1. modular and reusable
2. the variables and functions are encapsulated. They are not in contact with the global namespace and do not pollute global variables.
3. Only public methods are exposed. Other private methods are hidden to ensure that js does not conflict with each other.
Run: ------------------- view results -------------------
TIPS: If the browser cannot run properly, you can try to switch the browsing mode.
The code for the jQuery drop-down beautification search form is as follows:
Pure js (not dependent on existing frameworks) Focus text scrolling Effect
Script var lanrenzhijia ={}, H $ = function (id) {return document. getElementById (id)}, H $ = function (c, p) {return p. getElementsByTagName (c)} lanrenzhijia. slider = function () {return {init: function (id, options) {var ul = this. u = H $ ('ul ', H $ (id) [0], li = H $ ('lil', ul); this. l = li. length; this. index = 0; if (options. navId & options. curClass) {this. nav = H $ ('lil', H $ (options. navId), this. c = options. curClass ;} This. a = options. auto | 0; this. v = options. vertical | 0; H $ (id ). style. overflow = 'hiden '; H $ (id ). style. position = 'relative '; ul. style. position = 'absolute '; if (this. v) {ul. style. top = 0; this. h = options. height | li [0]. offsetHeight; ul. style. height = (this. l * this. h) + 'px ';} else {ul. style. left = 0; this. w = options. width | li [0]. offsetWidth; ul. style. width = (this. l * this. w) + 'px ';} this. pos (options. index | 0, this. a? 1:0) ;}, pos: function (pos, a) {clearInterval (this. u. posAnim); clearInterval (this. u. auto); var curPos = this. v? ParseInt (this. u. style. top): parseInt (this. u. style. left), correctPos = this. v? Pos * this. h: pos * this. w, direction = correctPos> Math. abs (curPos )? 1:-1; correctPos * =-1; this. index = pos; if (this. nav) {for (var I = 0; I
The above is the js (not dependent on the existing framework) Focus text rolling effect code shared for everyone. I hope you will like it.