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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:15:33+00:00 2026-06-10T16:15:33+00:00

I currently have a span tag which displays the onclick count for a button.

  • 0

I currently have a span tag which displays the onclick count for a button. Right now if the number exceeds three digits it will not fit within the span tag. Can I make the span tag adjustable or can I make its width adjustable, so that it will always encompass the onclick count?

I can change the width to accommodate more digits but I would like it to be adjustable because I cannot predict how many onclick events will actually occur.

var counts = {
  'Apples': 0,
  'Oranges': 0,
  'total': 0
};

   function countFruit(type) {
   document.getElementById('fruitCount').innerHTML = ++counts['total'];
   document.getElementById(type + 'Count').innerHTML = ++counts[type];
}


#OrangesCount{
z-index: 20;
position:absolute;
top:70px;
left:45%;
background-color:black;
width:80px;
border:2px solid green;
font-family: 'BPdotsUnicaseSquareBold';
font-size:25px;
color:yellow;
padding-right:4px;
padding-left:4px;
 }


#ApplesCount{
z-index: 20;
position:absolute;
color:yellow;
top:70px;
right:45%;
background-color:black;
width:80px;
border:2px solid green;
font-family: 'BPdotsUnicaseSquareBold';
font-size:25px;
   }

   <a id="buttonright" href="#" onclick="countFruit('Apples'); return false;">
   <a id="buttonleft" href="#" onclick="countFruit('Oranges'); return false;">

   <span id="ApplesCount"></span>
   <span id="OrangesCount"></span>
  • 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-10T16:15:35+00:00Added an answer on June 10, 2026 at 4:15 pm

    You just need to remove width from both css:

    #ApplesCount{
        z-index: 20;
        position:absolute;
        color:yellow;
        top:70px;
        right:45%;
        background-color:black;
        border:2px solid #550010;
        font-family: 'BPdotsUnicaseSquareBold';
        font-size:25px;
    }
    

    Here’s JSFiddle

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

Sidebar

Related Questions

I have the following HTML, with a span tag which contains an input field
I currently have a table of concentrations, which are linked to a table of
I am making a DOM builder which I have working succesfully but now I
Currently I have the following element <h6 class=header> Chance of Precipitation: <span data-bind=text: PrecipitationLabel></span>
Currently I have this code which calls the user template for each user node.
Currently i am working on simplepie rss reader in which i have to fetch
I have two span tags that contain content. The first span tag will hold
I have an HTML table with an object element and a span tag inside
I have a Span tag containing a IMG tag and another Span tag. I
I have a <span> tag, .lastMessageLink , with an <a> inside it, .lastMessageText .

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.