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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:32:53+00:00 2026-06-10T08:32:53+00:00

I did (.a input) auto increase width, when user type. But now i don’t

  • 0

I did (.a input) auto increase width, when user type.
But now i don’t know how to make (.b) at same time auto move to right? avoid overlapping
Thank you in advance.

if ($a.width()"+1px"){
 $b.animate({
  left: "+1px"
 }, 1000 );
};

html css

<input class="a" value="texttext">
<input class="b" value="texttext">

.a{
position: absolute;
left: 10px;
top: 22px;
width: 100px;
font-size: 19px;
}
.b{
position: absolute;
left: 110px;
top: 22px;
width: 100px;
font-size: 19px;
}
  • 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-10T08:32:54+00:00Added an answer on June 10, 2026 at 8:32 am

    I think you need a different approach to this problem. You need to hook to the keyup event of input.a and get the text width as you’re typing the text. However, you cannot get the width of the text by normal means so you would need to employ some sort of cloned div to be updated with input.a‘s text every time you type:

    $('#aclone').html($('input.a').val());
    
    $('input.a').keyup(function () {
    
        var clone_width, apos, bleft;
    
        // make clone contain what input.a contains
        $('#aclone').html($(this).val());
    
        // get the width of cloned text
        clone_width = $('#aclone').width();
    
        // if it's bigger than input.a's current size, resize it
        if (clone_width > $(this).width()) {
            $(this).width(clone_width);
        }
    
        // calculate position for b
        apos = $(this).position();
        bleft = apos['left'] + $(this).width();
    
        // adjust input.b's position
        $('input.b').css({'left': bleft});
    
    });
    

    Check this out: http://jsfiddle.net/aemhd/

    P.S.: my fiddle has the clone div shown. If you want to hide it, do not use display:none as the browser wouldn’t able to calculate it’s width if it’s hidden, instead just position it outside of the viewport using top:-9999px;left:-9999px; in CSS.

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

Sidebar

Related Questions

sometime due to wrong input from user side, mail bounce and did not reach
<div style=display: inline-block; margin: 0 auto;> <input id=abc type=button value=button /> </div> I try
I'm trying to make a simple application form were user can input data like
I did some research about a question but didn't find any answer. And now,
hay all, I just did the following: a = input(give a word: ) b
Did you ever have the following situation: you need to store information, but a
Did about 30 minutes worth of searching, found lots of relevant info, but none
Did I not get enough sleep or what? This following code var frame=document.getElementById(viewer); frame.width=100;
Did actually someone make already a tutorial that shows how to customize an UITableView?
i want to compare through 2 information, one is user input and second is

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.