Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8396895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:39:08+00:00 2026-06-09T20:39:08+00:00

I have a page where some tweets are dynamically fetched from Twitter. It’s like

  • 0

I have a page where some tweets are dynamically fetched from Twitter. It’s like a news ticker thing. The whole page is over here http://jsfiddle.net/R6D4R/.

The page works in jsfiddle because the content is already in there, whereas the content on the live site is dynamically placed into the divs. The ticker() function still works, but the if statement is not taking effect. Could anyone help me fix this?

EDIT:

Sorry guys, I didn’t clarify why the if statement is there for. The function works on its own, but I don’t want the function to run when there’s only one tweet. That’s why I have if (tickerli.length != 1). I should probably use > 1 instead of != 1, but you get the idea

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:39:09+00:00Added an answer on June 9, 2026 at 8:39 pm

    OK, completely redoing my answer as I was confused about what you were asking:

    To deal with dynamically added elements in your ticker() function, you have to re-evaluate your selector on each call of the function like this:

    $(function(){
        function ticker() {
            var tickerLi = $('.tweet_list li');
            if (tickerLi.length > 1) {
                tickerLi.first().fadeOut(function() {
                   $(this).appendTo($('.tweet_list')).fadeIn();
                });
            }
        }
    
        setInterval(ticker, 2000);
    }
    

    This was the previous answer when I thought you wanted help with event handling on dynamically added elements.

    To install event handlers that will work on elements that are added dynamically in the future, you need to use delegated event handling. To do, you can use:

    $(static parent selector).on(event, selector of dynamic element, fn);
    

    Note: there are two forms of .on(), one is static and one is dymamic (uses delegated event handling). To use dynamic event handling, you bind the .on() handler to a parent element that is not dynamic and then you pass (as the 2nd argument to .on(), a selector that matches the dynamic element).

    In your jsFiddle for a click handler on the tweet text, that would work like this:

    $('twitter-container-34').on('click', '.tweet_text', function() {
        // your event handling code here
    });
    

    Note: jQuery .on() was added in jQuery v1.7. For earlier versions of jQuery, use .delegate().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page with some very basic examples that use HTML/CSS/JavaScript. I'd like
I have an app that can show a stream of tweets from a twitter
i have a page with some standard stuff like header links, links on the
I have a twitter feed displaying my tweets on a page. I want to
I have some page, it's url is like http://www.domainname.com/m1.php?#m2.php?more=apple&starting=1 . I want get the
I have a page saving some data from textboxes to the back end using
I have a page composed from multiple partial asp.net mvc views rendered dynamically. How
I have a page with some dynamically added buttons. If you click a button
I have a page with some user selectable options and a button that, when
I have a page with some checkboxes and a submit button. I use AJAX

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.