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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:11:23+00:00 2026-06-01T11:11:23+00:00

I am trying to have a text box resize on click. in the head:

  • 0

I am trying to have a text box resize on click.

in the head:

<style>
.expand {
    height: 1em;
    width: 50%;
    padding: 3px;
}
</style>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script>
$('textarea.expand').focus(function () {
    $(this).animate({ height: "1000px" }, 500);
});
</script>

and body:

<form>
<textarea class="expand" rows="1" cols="10"></textarea>
</form>

it is not expanding for me.

  • 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-01T11:11:24+00:00Added an answer on June 1, 2026 at 11:11 am

    The reason it doesn’t work is that you haven’t specified event-binding on $(document).ready(), so the events are bound before the elements exist in the DOM. Try this:

    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script>
    $(document).ready(function(){
        $('textarea.expand').focus(function () {
            $(this).animate({ height: "1000px" }, 500);
        });
    });
    </script>
    

    JS Fiddle demo.

    It’s also worth noting that, in the more up-to-date browsers, you don’t necessarily require JavaScript for this:

    .expand {
        height: 1em;
        width: 50%;
        padding: 3px;
        -webkit-transition: all 1s linear;
        -0-transition: all 1s linear;
        -ms-transition: all 1s linear;
        -moz-transition: all 1s linear;
        transition: all 1s linear;
    }
    
    .expand:focus {
        height: 1000px;
        -webkit-transition: all 1s linear;
        -0-transition: all 1s linear;
        -ms-transition: all 1s linear;
        -moz-transition: all 1s linear;
        transition: all 1s linear;
    }​
    

    JS Fiddle demo.

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

Sidebar

Related Questions

I have one text box and button in asp.net like <tr> <td style=width: 100px>
I have developed a text box and I am trying to write this data
I'm trying to get the text from a text box. I have 2 input
Basically what I'm trying to achieve is the following:- I have a text box
I have text-box in some form in access 2007. I am trying to replace
I'm trying to have a text box that has syntax highlighting. To avoid the
In the following code i am trying to have a text box and a
I am trying to have an image instead of a text box. Googling I
I have a text box that updates/edits my database, after thousands of errors trying
I have a text box in a grid, the textbox has a style applied

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.