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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:57:06+00:00 2026-05-25T14:57:06+00:00

Okay, I have a number inside a tiny box, although the output is dynamic

  • 0

Okay, I have a number inside a tiny box, although the output is dynamic it is predictable enough to know that there will more than likely be no more than 5 characters in this box. What I want to do is, have a jQuery script that counts the number of characters in the box and adds the number as a class to the box. Like This:

<div class="num">2443</div>

$('.num').addClass(numOfChars); 
// numOfChars will be different for each, but will be detected

When the script is finished, the box will look like this:

<div class="num 4">2443</div>

If the box had 5 characters in it it would look like this:

<div class="num 5">12556</div>

There will be multiple boxes present on a page so it needs to be able to run for all of them. Is there any method of doing such a thing?

Please ask questions. thanks.

  • 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-25T14:57:06+00:00Added an answer on May 25, 2026 at 2:57 pm
    <script type="text/javascript">
    
    $(document).ready(function() {
      $('.num').each(function() {
        var l = $(this).html().length;
        $(this).addClass('size' + l);
      });
    });
    
    </script>
    <style type="text/css">
      .num { border: solid 1px red; }
      .size4 { width: 100px; }
      .size5 { width: 200px; }
    </style>
    
    <div class="num">2443</div>
    <div class="num">12556</div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my situation I have a number of files that will be stored on
Okay I have a large CRUD app that uses tabs with Forms embedded in
So, let's say that I have a VBA application inside of whatever Office Application.
I have some long-running operations that number in the hundreds. At the moment they
Okay, so say i want to find factors of a number a. I know
I have a resultSet that has a different number of results every time, and
Okay, so I need to have the output look like a diamond of asterisks,
I have a SQL query that returns a number of results (unfortunately, the number
Okay, my dilemma is this. I have an admin page that I use to
Okay, so, I have a couple text files that are written to and read

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.