TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-17-2009, 10:24 AM   #1 (permalink)
The Acquainted
 
Hightower's Avatar
 
Join Date: May 2009
Location: Durham, UK
Posts: 134
Thanks: 9
Hightower is on a distinguished road
Default News Ticker

I have got the following code for jQuery (can't remember where from):

javascript Code:
var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline = 0;
   
$(document).ready(function(){
    headline_count = $("div.headline").size();
    $("div.headline:eq(" + current_headline + ")").css('top', '5px');

    headline_interval = setInterval(headline_rotate,5000);
    $('#scrollup').hover(function() {
        clearInterval(headline_interval);
    }, function() {
        headline_interval = setInterval(headline_rotate,5000);
        headline_rotate();
    });
});

function headline_rotate() {
    current_headline = (old_headline + 1) % headline_count;
    $("div.headline:eq(" + old_headline + ")")
        .animate({top: -205},"slow", function() {
            $(this).css('top', '210px');
        });
    $("div.headline:eq(" + current_headline + ")")
        .animate({top: 5},"slow")
    old_headline = current_headline;
}

It scrolls through any divs with a headline class, displaying each one in turn.

It works nicely except when I first load the page every headline is displayed. Can anybody help me modify the jQuery code so that every headline apart from the first is hidden when the page is initially loaded.
__________________
Hightower's Softpolio
Send a message via MSN to Hightower
Hightower is offline  
Reply With Quote
Old 08-17-2009, 10:41 AM   #2 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Source: http://www.learningjquery.com/2006/1...eadline-reader
Salathe is offline  
Reply With Quote
Old 08-17-2009, 11:15 AM   #3 (permalink)
The Acquainted
 
Hightower's Avatar
 
Join Date: May 2009
Location: Durham, UK
Posts: 134
Thanks: 9
Hightower is on a distinguished road
Default

Thanks - checked my code with that and I can't see any differences... So why do all my items show when the page loads instead of hiding all but the first one?
__________________
Hightower's Softpolio
Send a message via MSN to Hightower
Hightower is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
News - Phlox Project codefreek TalkPHP Developer Team 1 11-10-2012 07:29 AM
AJAX ticker in jQuery Orc Javascript, AJAX, E4X 3 02-09-2009 05:31 AM
MySQL join total delayedinsanity MySQL & Databases 3 07-24-2008 03:53 AM
My News Script [No errors] - Just wont work! codefreek Absolute Beginners 5 07-03-2008 09:25 PM


All times are GMT. The time now is 03:44 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design