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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:02:32+00:00 2026-06-07T22:02:32+00:00

Basically, I a trying to change the height of a textarea based on how

  • 0

Basically, I a trying to change the height of a textarea based on how many lines it has which is kind of irrelevant to the question, but here is the coding of adding event listeners to every textarea without using a for loop:

$('textarea').keyup(function(event) {
    this.style.height = Math.floor(this.scrollHeight / 11) + '.1em';
});

And here is my for loop:

for (i=0; i<$('textarea').length; i++) {
    $('textarea')[i].style.height = Math.floor($('textarea')[i].scrollHeight / 11) + '.1em';
}

The for loop works perfectly, but just for the sake of clean and efficient coding I would like for it to look more like the first coding without a for loop being needed.

Also, a note that all of this inside a if document is ready function.

  • 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-07T22:02:34+00:00Added an answer on June 7, 2026 at 10:02 pm

    you can try each() method:

    $('textarea').each(function(){
         $(this).css('height', Math.floor(this.scrollHeight / 11) + '.1em')
    })
    

    jQuery.each()

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

Sidebar

Related Questions

I am basically trying to solve the coin change problem through recursion and here
I'm trying to LEFT JOIN a table based on a CASE result. Basically, I
Basically I'm trying to change the Canvas.Left property of an Ellipse Silverlight control in
Good afternoon everyone So, I'm trying to dynamically change textview's properties. basically, I defined
I'm trying to basically trying to separate a specific amount of text from the
I'm basically trying to iterate through a dict and print out the key /
I'm basically trying to extract a Mac application from a zip file using QuaZip.
I'm basically trying to create a url friendly query string with user input. The
I'm basically trying to make my js and css files dynamic. I've tried a
What im basically trying to do is to confirm the identity of the user

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.