jQuery News Ticker

Cool news ticker! Seems familiar...

Taking inspiration from the BBC News website ticker, jQuery News Ticker brings a lightweight and easy to use news ticker to jQuery.

So how do I use this thing?!

First, download the zip file containing the plugin and the example / documentation for the news ticker:

The latest version of jQuery News Ticker is v1.8 which was released on 13th November 2011 (view release history).

v1.8 - 2011-11-13 - Reduced amount of HTML needed, multiple tickers now possible, title positioning bug fixed

v1.7 - 2011-05-14 - Support for jQuery 1.6+

v1.6 - 2011-04-25 - Support for right-to-left languages, orders lists and a few bug fixes

v1.5 - 2011-02-23 - Various bug fixes

v1.4 - 2010-11-21 - jQuery News Ticker now has support for loading content via an RSS feed (1.4 compatible version only)

v1.3 - 2010-10-25 - jQuery News Ticker now has an option for fading between news items (1.4 compatible version only)

v1.2 - 2010-06-26 - jQuery News Ticker is now compatible with jQuery 1.3.2, see the zip file for this version.

v1.1 - 2010-06-23 - Moved titleText option outside of dom object in settings, see options below for more detail. Thanks to J Singh.

v1.0 - 2010-06-05 - Initial release of jQuery News Ticker.

And what do I do with these files?

If you want the fully styled version (as above) of the news ticker, use the files from the zip and include the following in your HTML:

<link href="css/ticker-style.css" rel="stylesheet" type="text/css" />
<script src="jquery.ticker.js" type="text/javascript"></script>

Unsurprisingly you will need to include jQuery (1.4.2 or above) to make all this work, I recommend using Google's Ajax Libraries API for the very latest version.

Apologies to anyone using an earlier version, I may update the code be compatible with jQuery 1.3 if there is enough demand. A version of jQuery News Ticker that is jQuery 1.3.2 compatible can be downloaded here: jquery.ticker.js. Please note that this version does not have all of the features of jQuery News Ticker and is no longer being actively developed.

Don't I need some HTML to make this news ticker work?

Yes you do, all you need is the following HTML:

<ul id="js-news" class="js-hidden">
    <li class="news-item"><a href="#">This is the 1st latest news item.</a></li>
    <li class="news-item"><a href="#">This is the 2nd latest news item.</a></li>
    <li class="news-item"><a href="#">This is the 3rd latest news item.</a></li>
    <li class="news-item"><a href="#">This is the 4th latest news item.</a></li>

jQuery News Ticker will also work fine with an <ol> element to contain the news items.

And how do I make jQuery do its magic on this thing?

To get jQuery News Ticker working, you'll need to also add this code to your page:

<script type="text/javascript">
    $(function () {

Ok, what else?

That's everything to get the news ticker working! If you get stuck have a look at the source of the example on this page to see what's what.

You'll probably want to dive into the CSS to change the visual style to your liking, but you're on your own with that one!

Ok, that's great and everything but I want to fiddle with the settings...

Ok, so here are the settings that can be changed, shown with their default values:

$(function () {
        speed: 0.10,           // The speed of the reveal
        ajaxFeed: false,       // Populate jQuery News Ticker via a feed
        feedUrl: false,        // The URL of the feed
	                       // MUST BE ON THE SAME DOMAIN AS THE TICKER
        feedType: 'xml',       // Currently only XML
        htmlFeed: true,        // Populate jQuery News Ticker via HTML
        debugMode: true,       // Show some helpful errors in the console or as alerts
  	                       // SHOULD BE SET TO FALSE FOR PRODUCTION SITES!
        controls: true,        // Whether or not to show the jQuery News Ticker controls
        titleText: 'Latest',   // To remove the title set this to an empty String
        displayType: 'reveal', // Animation type - current options are 'reveal' or 'fade'
        direction: 'ltr'       // Ticker direction - current options are 'ltr' or 'rtl'
        pauseOnItems: 2000,    // The pause on a news item before being replaced
        fadeInSpeed: 600,      // Speed of fade in animation
        fadeOutSpeed: 300      // Speed of fade out animation

Woah, that made no sense, how do I use these settings?

Any changes you want to make to the default settings are passed in to the call of the news ticker, like so:

<script type="text/javascript">
    $(function () {
            speed: 0.10,
            htmlFeed: false,
            fadeInSpeed: 600,
            titleText: 'Latest News'

Which browsers does this work with?

So far this plugin had been tested as working with: IE6+, FF 3.6+, Chrome, Safari, Safari Mobile and Opera.

If you do find any bugs, or any further browser compatibility, head over to GitHub and let me know.

What license is this released under?

GPL v2 - read more here: http://www.gnu.org/licenses/gpl-2.0.html

What about loading content from a feed?!

Yeah, well the population of news items will be from HTML only for now I'm afraid...

You're in luck! The latest update to jQuery News Ticker introduced support for loading content of an RSS feed via ajax!

The basic code you want for using an RSS feed is something like:

<script type="text/javascript">
    $(function () {
            htmlFeed: false,
            ajaxFeed: true,
            feedUrl: 'PUT THE URL OF THE RSS FEED HERE - e.g. http://example.com/rss.xml',
            feedType: 'xml'

What should the XML look like? The standard RSS format found here will work just fine.

It's worth noting at this point that the RSS feed must be on the same domain that the news ticker as jQuery does not allow cross-domain requests.

If you want to use a feed from a different domain you'll need to either implement a server-side solution or use something like a JSON proxy.

Further support for loading new items from different feed sources will be coming in a future release, so stay tuned!

Hey, this is really great work - how can I thank you?

If you are feeling generous donations via PayPal are always welcome!

Copyright © 2011

Fork me on GitHub