<ol id="sample" class="ticker">
<li>Item 1. Lorem ipsum doler sit amet.</li>
<li>Item 2. Lorem ipsum doler sit amet.</li>
<li>Item 3. Lorem ipsum doler sit amet.</li>
<li>Item 4. Lorem ipsum doler sit amet.</li>
<li>Item 5. Lorem ipsum doler sit amet.</li>
</ol>
/**
* @author Matt Hinchliffe <http://www.maketea.co.uk>
* @modified 13/05/2011
* @title Simple jQuery News Ticker
*/
(function($)
{
$.fn.Ticker = function(options)
{
var defaults = {
// Time to display each news item. (integer, milliseconds)
pause: 5000,
// Time taken to fade in next news item. (integer, milliseconds)
fadeIn: 800,
// Time taken to fade out current news item. (integer, milliseconds)
fadeOut: 800,
// Pause between displaying each item when fading between items. (integer, milliseconds)
delay: 500,
// Next news item typed out one character at a time. If false item will fade in. (boolean)
typewriter: true,
// Time to type each character if using the typewriter effect (integer, milliseconds)
speed: 35,
// Character to use to mimic a computer cursor if using the typewriter effect (string|boolean)
cursor: '_'
};
// Merge default options with user options
var opts = $.extend({}, defaults, options);
return $(this).each(function()
{
var list = $(this), typewriter = {}, interval;
// Activate ticker and display first item
list
.addClass('ticker-active')
.children(':first')
.css('display', 'block');
function changeItem()
{
var item = list.children(':first'),
next = item.next(),
copy = item.clone();
clearTimeout(interval);
// Append copy of current item to bottom of list
$(copy)
.css('display', 'none')
.appendTo(list);
// Fade current item out, remove from DOM then animate the next item
item.fadeOut(opts.fadeOut, function()
{
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.