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 7632071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:31:31+00:00 2026-05-31T06:31:31+00:00

I have a ul list that is dynamically generated upon page load via JavaScript.

  • 0

I have a ul list that is dynamically generated upon page load via JavaScript.
The code that is generated can be seen here (with irrelevant items removed):

<ul class="tweet_list"><li class="tweet_first tweet_odd"></li></ul>

CSS:

​ul.tweet_list li {
    height: 55px;
    line-height: 55px;
    overflow: hidden;
    padding: 0.5em !important;
    vertical-align:middle;
}​

I’m trying to change the CSS line-height property based on the number of words in the Tweet (if over 9 words, I want the line height to change from 55px to 24px). Here is my JS:

$(function(){
    var $tweet = $(".tweet_first");
    var $numWords = $tweet.text().split(" ").length;
    if (($numWords >= 1) && ($numWords < 10)) {
        $tweet.css("line-height", "55px");
    }
    else {
        $tweet.css("line-height", "24px");
    }    
});

Here’s a screenshot of the widget http://justpaste.it/twitter-widget

EDIT: My code isn’t working. For some reason nothing I have above will change the line-height dynamically unless I go into my styles.css file and actually change the line height. HOW CAN I CALL IN MY JS THE ul.tweet_list li AND APPLY THE line-height property directly to it?

UPDATE: If someone can just tell me how to dynamically change the CSS portion, I can figure out how to detect the number of characters in the tweet. So, using Javascript, how can I change this:

​ul.tweet_list li {line-height: 55px; }​

to this:

​ul.tweet_list li {line-height: 24px; }​

UPDATE 2:
Code that calls the tweet:

jQuery(function($){
      $(".tweeter_widget").tweet({
        join_text: "auto",
        username: "twitter_username",
        avatar_size: null,
        count: 1,
        auto_join_text_default: "",
        auto_join_text_ed: "",
        auto_join_text_ing: "",
        auto_join_text_reply: "",
        auto_join_text_url: "",
        loading_text: "loading tweets..."
      });
    }); 
  • 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-05-31T06:31:32+00:00Added an answer on May 31, 2026 at 6:31 am

    I think it shold be:

    $(function(){
        var $tweet = $(".tweet_first");
        var $numWords = $tweet.text().split(" ").length;
        if (($numWords >= 1) && ($numWords < 10)) {
            $tweet.css({ "font-size": "55px", "line-height": "55px" });
        }
        else {
            $tweet.css({ "font-size": "24px", "line-height": "24px" });
        }    
    });
    

    UPDATE: Ok, maybe I’ve understand:

    Taking a look to the documentation of the plugin you’ve used I see that you could bind an eventhandler like “loaded”, that fires after the tweet is rendered. So you’ve to change your code with:

    jQuery(function($){
      $(".tweeter_widget").tweet({
        join_text: "auto",
        username: "twitter_username",
        avatar_size: null,
        count: 1,
        auto_join_text_default: "",
        auto_join_text_ed: "",
        auto_join_text_ing: "",
        auto_join_text_reply: "",
        auto_join_text_url: "",
        loading_text: "loading tweets..."
      }).bind("loaded", function() {
        var $tweet = $(".tweet_first"); // maybe using  $(this)  is better
        var $numWords = $tweet.text().split(" ").length;
        if (($numWords >= 1) && ($numWords < 10)) {
            $tweet.css({ "font-size": "55px", "line-height": "55px" });
        }
        else {
            $tweet.css({ "font-size": "24px", "line-height": "24px" });
        }
      });
    });
    

    Please try, is untested 🙂

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

Sidebar

Related Questions

I have a page that contains dynamically generated Dropdown List controls and I want
I have a selection list that is generated dynamically, it lists a number of
The Scenario I have a table on a web page that is dynamically generated
On my page, I have a dynamically generated list of radio buttons (created with
I have a list of dynamically generated divs that represent panels for selecting various
How can I filter some items that are in a dynamically generated list in
I have a drop down list that is dynamically generated using a mySQL database
I have a list of pages that are dynamically generated with a echo statment.
I have a routine that dynamically changes a select list's selected option when the
I have a query that is dynamically built after looking up a field list

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.