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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:36:00+00:00 2026-06-17T09:36:00+00:00

Can’t seem to find out to do this in either html or JS (or

  • 0

Can’t seem to find out to do this in either html or JS (or maybe even jquery?).

I have a text-box that echo’s whatever is typed into it in an input box more down the page. This echo box needs to auto-fit to whatever text is inside it so that it doesn’t have this huge white space spot after the text.

Any ideas how to auto-fit a input field to text that is inserted into it?

  • 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-17T09:36:00+00:00Added an answer on June 17, 2026 at 9:36 am

    I think you’re looking for something like this: http://jsfiddle.net/ener3/

    $("#in").keyup(function(){
      var tmp = $("<span>")
                .text(this.value)
                .css("font", $("#out").css("font"))
                .appendTo("body"),
          wid = tmp.width();
      tmp.remove();
    
      $("#out").val(this.value).width(wid);
    });
    

    where #in is the id of the input, and #out is the textbox you want to autosize.

    You can add this to the head of the page like so:

    <script type="text/javascript">
    $(function(){
        // paste the above code here
    });
    </script>
    

    Make sure you put the script tag after your jQuery include:

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    

    You can replace 1.8.3 with the version of jQuery you want to target. I wouldn’t recommend using jQuery-latest to start as you’d have to account for potential deprecation where applicable.

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

Sidebar

Related Questions

Can someone maybe tell me why this is not working? I have used echo
Can anyone help me trying to find out why this doesn't work. The brushes
I have a jquery bug and I've been looking for hours now, I can't
Can I have a project that has some parts written in c and other
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Can any one help me in sorting this out in sed/awk/perl Input file Start
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Can find why i get this error can someone help? package Android.data; public class
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
Can I order my users in the database, so I don't have to say

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.