Announcement rolling display plug-in and announcement rolling plug-in

Source: Internet
Author: User
Tags sample html code

Announcement rolling display plug-in and announcement rolling plug-in

Announcement rolling display plug-in (written by jQuery plug-in)

Plug-in code:

/***** Announcement rolling display plug-in */(function ($) {$. fn. scrollNews = function (width) {if (this. find ("li "). length = 0) return; var ulWidth = 0; var currentMarginLeft = 0; var scrollStart = true; // initialize the div property this. parent (). width (width); this.parent().css ("overflow", "hidden"); // initialize the ul attribute this.css ("float", "left "); // initialize the li property var liMarginRight = 20; this. find ("li" ).css ("margin-right", liMarginRight. toString () + "px"); this. find ("li" ).css ("float", "right"); // initialize the ul width and the current margin-left this. find ("li "). each (function () {ulWidth + = $ (this ). width () + liMarginRight + 1 ;}); this. width (ulWidth); currentMarginLeft = width; this.css ("margin-left", currentMarginLeft); // The scrolling method defines var scroll = function (obj) {setInterval (function () {if (scrollStart) {obj.css ("margin-left", currentMarginLeft. toString () + "px"); currentMarginLeft-= 1; if (currentMarginLeft <-ulWidth) currentMarginLeft = width ;}, 50 );}; // display div this.parent().css ("visibility", "visible"); // call the scroll (this) method; this. mouseover (function () {scrollStart = false;}); this. mouseout (function () {scrollStart = true}) ;}}) ($ );View Code

Sample HTML code:

<Div style = "float: right; margin-right: 10px; margin-top: 5px; font-size: 15px; visibility: hidden; "> <ul id =" ulgg "> <! -- BEGIN noticeList --> <li> <a href = "# {noticeLink}"> <span style = "color: # ff0000;">★# {Notice. NoticeTitle} </span> </a> </li> <! -- END noticeList --> </ul> </div>View Code

Sample JS Code:

$ (Function () {$ ("# ulgg"). scrollNews (450 );});View Code

 

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.