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

  • SEARCH
  • Home
  • 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 6224813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:43:59+00:00 2026-05-24T08:43:59+00:00

Pretty simple task: using jquery I need to calculate the width of an input

  • 0

Pretty simple task: using jquery I need to calculate the width of an input before the input is visible on the screen.

http://jsfiddle.net/ajbeaven/mKQx9/

Here is the code for convenience:

<div style="display:none;">
    <input />
</div> 

<script type="text/javascript">
    $(function () {
        alert($('input').width());
        $('div').show();
    });
</script>

Alert always shows 0

How do I calculate width without having to forcibly make the element visible, calculate the width, then hide them again?

  • 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-24T08:43:59+00:00Added an answer on May 24, 2026 at 8:43 am

    You can’t. Hidden elements, by definition, have a width of 0.

    If you need to calculate dimension, you might be able to get away with “showing” it offscreen (at some odd position, like left: -9999px; top: -9999px.

    Also, this appears to be a duplicate of: jQuery – Get Width of Element when Not Visible (Display: None)

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

Sidebar

Related Questions

The task is pretty simple, but I've not been able to come up with
Ok, this started out as a pretty simple task to import a customers data
Pretty simple task, but the source code doesn't do required job... Please advise. There
I want to achieve a pretty simple task, but none of the solutions here
.NET 4 has a Class - Task . It's pretty interesting and I would
Pretty simple scenario. I have a web service that receives a byte array that
Pretty simple question: When i have a persistable object, it usually has a property
Pretty simple question, I'm writing an XML document and i'm not sure how to
Pretty simple question. I have a few ASP RequiredFieldValdators checking some text boxes. Out
Pretty simple question. I've got some Polygons and GroundOverlays defined in KML. Is there

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.