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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:42:47+00:00 2026-06-12T18:42:47+00:00

I am trying to create a textbox that is horizontally resizable, draggable, and dynamically

  • 0

I am trying to create a textbox that is horizontally resizable, draggable, and dynamically changes its height based on what is typed inside. Here is my code so far

HTML:

<div id="text_container">
    <div id="my_text" contenteditable="true"></div>
</div>

CSS:

#text_container {
    border: #4A4A4A 2px solid;
    background: #EFEFEF;
    width: 150px;
    padding: 5px;
}

#my_text {
    width: 100%;
    border: #000 1px solid;
    background: #fff;  
    font-size: 40px;
}

jQuery:

$('#text_container').resizable( { handles: 'e' } ).draggable();

$('#my_text').keydown( function() {
    $('#text_container').css( { height: ($( this ).height() + 2) } );
});

$('#text_container').resize( function() {
    $('#text_container').css( { height: ($( '#my_text' ).height() + 2) } );
});

This makes the box change correctly with the horizontal resizing, but when I need to have it resize by skipping down a line, I have to type in one more character than I should have to. Using keypress gives the same results, and keyup doesn’t resize until the key has been released, so if a person is holding down a key, it won’t resize the div until the person releases the key, which doesn’t seem optimal to me. Any thoughts on this?

Here is a fiddle:
http://jsfiddle.net/UA3QS/65/
​
​

  • 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-12T18:42:49+00:00Added an answer on June 12, 2026 at 6:42 pm

    The input value is not set to the new value in keydown. You can use the keyup event instead:

    $('#my_text').keyup( function() {
        $('#text_container').css( { height: ($(this).height() + 2) });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a editable textbox with HTML/CSS/Javascript that looks and functions like
i'm trying to create a simple autocomplete textbox that takes the suggestions from an
I am trying do create a Textbox in Wpf that has a Label in
I'm trying to create a server control, which inherits from TextBox, that will automatically
I'm trying to create a method that will custom validate any TextBox control passed
I trying to create new class object that derivative from TextBox - If there
I am trying to create an app with no of clearable textboxes (a textbox
I am trying to create a status window which content(textbox) should change in a
Ok so I am trying create a login script, here I am using PHP5
I'm trying to create a binding from my custom control to objects that are

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.