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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:22:00+00:00 2026-05-28T08:22:00+00:00

I have a div being refreshed every x seconds or so. Within this div

  • 0

I have a div being refreshed every x seconds or so. Within this div I have a textarea. What I’m trying to do is if the user starts to type in this textarea, then don’t refresh the div, otherwise, keep refreshing.

This is the JS to detect the keydown in the textarea, the problem I’m having is that it’s making typing in the textarea laggy because the JS keeps running for every keystroke. How I can I only make this run once?

<script type="text/javascript">
$("#comment_textarea").live('keydown', function() {
   $('form #comment_textarea').elastic();   
   clearInterval(auto_refresh); auto_refresh = 0;
});
</script>
  • 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-05-28T08:22:01+00:00Added an answer on May 28, 2026 at 8:22 am

    It’s most likely the elastic plugin you’re calling, because clearing an interval every keystroke shouldn’t create much (if any) lag.

    If the elastic plugin is something that changes the textarea when the user focus’ the input element then you can bind it to the focus event instead so it doesn’t run each keystroke:

    <script type="text/javascript">
    $(document).delegate("#comment_textarea", "keydown", function () {  
        clearInterval(auto_refresh);
        auto_refresh = 0;
    }).delegate("#comment_textarea", "focus", function () {
        $('#comment_textarea').elastic(); 
    });
    </script>
    

    Notice I used .delegate() instead of .live(). .delegate() allows you to select a root element other than document.

    If you need to have the elastic plugin call inside your keydown event handler or are still having lag issues you can always check the value of the auto_refresh variable:

    if (auto_refresh !== 0) {
        clearInterval(auto_refresh);
        auto_refresh = 0;
    }
    

    This code would go inside your keydown event handler.

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

Sidebar

Related Questions

I have many inputs in a few divs, every div is being hidden and
I am trying to accomplish something that seemed quite simple... I have 3 div
I have a div which has some stuff in it, and the user has
I have a div that is being used an a email newsletter signup form.
I have a div that is being used as a dialog with jQuery's .dialog()
I have div called panel that itself contains another div. When a user clicks
I have a several divs that a refreshed using Ajax after the user clicks
I'm trying to make the rows of this table start out disabled and then
I have been trying to basically create a div for each row of the
Basically, I have one div(divNew) which is being populated with content from another page(thread.php)

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.