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.
Javascript code uses function-type 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. it encapsulates variables and functions, and is not in contact with the global namespace and does 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 (without relying on the current framework) 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.