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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:15:30+00:00 2026-06-17T22:15:30+00:00

I am using the following keyup event handler . <script type=text/javascript> $(‘.someClass’).on(‘keyup’, function(e){ console.log($(this).val());

  • 0

I am using the following keyup event handler .

<script type="text/javascript">
  $('.someClass').on('keyup', function(e){
    console.log($(this).val());
  });
</script>

When writing the keyup event , and typing “qwe”.
actual result : “qwe”
desired result :
“q”
“qw”
“qwe”

i simplified it here , but i also tried with closure , what is the right way?

  • 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-17T22:15:31+00:00Added an answer on June 17, 2026 at 10:15 pm

    I found a tricky (ugly?) solution that works even if you type quickly:

    var prevVal = '';
    $('.someClass').on('keypress', function (e) {
        prevVal += String.fromCharCode(e.which);
        console.log(prevVal);
    }).on('keyup', function() { prevVal = $(this).val() });
    

    See here: http://jsfiddle.net/FZHZJ/1/

    Note it doesn’t print on modifier keyup events (ie. backspace, shift, arrows) – if you want that also then reply and I’ll try to fix it.

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

Sidebar

Related Questions

I'm building a calculator, and am using the following: jQuery(function($) { $('#Quantity').keyup(function() { console.log($(this).val());
I am using the following jQuery functionality to count words in real time: $(input[type='text']:not(:disabled)).each(function(){
I am using the following code: $(function(){ $(.aucomplete).live(keyup, function(){ var all_analysts = [<TMPL_VAR ALL_TARGETS>];
I have the following code to count and trigger some functions using jQuery: jQuery('#input_guideName').keyup(function(e)
Using following code I try to get updated list of checkbuttons' corresponding text values,
I am using following code to show a spinning wheel: $(#loading) .hide() .ajaxStart(function(){ $(this).show();
I am using following command for start the production server. nohup ruby script/server webrick
I am using following code to get bitmap from url. This function is used
I want to capitalize all words in an input (using keyup function) to format
The following code currently only generates a search query whenever a keyup event happens.

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.