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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:31:35+00:00 2026-06-05T18:31:35+00:00

I’m trying to get the value of an <input type=text> with the method keyup

  • 0

I’m trying to get the value of an <input type=text> with the method keyup from jQuery but whenever i log it it logs undefined.

Here is my code:

$.each(editables,function(i){
    current  = $(editables[i]);
    var value;              
    current.on('keyup', function(){
        value = $(this).val();
        console.log( value );
    });
    current.html( value );
});

Thanks in advance

EDIT

I have a table wich displays all the information of a database, and i have a button to edit the information, what i do is i convert all of the <td class="editable"> to an <input type="text"> and i’m trying to get the value from them after i click the button again, i will send the info via $.post() but i can’t get the value from these inputs

EDIT 2
Here is the full code of the handler hope it helps, thanks to all that have contributed
$(‘.edit’).on(‘click’,function(e){

    $this = $(this);
    editables = $this.parents('tr').find('td.editable');

    if($this.text() == "Save"){
        row  = $this.parents('tr');
        table = row.data('table');
        id = row.data('id');
        field = row.data('field');
        /*
        $.each(editables,function(i){
            current  = $(editables[i]);
            var value;              
            current.on('keyup', function(){
                value = $(this).val();
                console.log( value );
            });
            console.log( current );
            current.html( value );
        });
        */
        editables.each(function(i){
            var current = $(this);
                value;
            current.on('keyup',function(){
                value = $(this).val();
                console.log(value);
            })
        });

        $this.val('Edit');  

    } else {            

        $.each(editables,function(i){
            current  = $(editables[i]);
            currentValue = current.text();

            current.html("<input type='text' value='"+currentValue+"'></input>");
        });     

        $this.val('Save');
    }

    e.preventDefault();
});

UPDATE
there was something else wrong in my code outside of the one i shared here that messed up the funcionality.

Thanks to everyone who helped

  • 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-05T18:31:37+00:00Added an answer on June 5, 2026 at 6:31 pm

    editables is still the <td> tag based on your updated code, not the input that is now inside. Use the .find to target the new input tags instead.

       editables.find('input').each(function(i){
            var current = $(this);
                value;
            current.on('keyup',function(){
                value = $(this).val();
                console.log(value);
            })
        });
    

    (Answer to updated question above)


    (Answer to original question below)

    First, you need to move your .html() statement inside the .on('keyup'. Otherwise it will run only once and before keyup has occurred. Essentially what you are doing is:
    1. initialize value. 2. set current.html to the initialized variable with no value (undefined). 3. Listen for keyup. 4. On keyup change value of the variable and do nothing.

    When .html() is inside the .on it will run only after keyup and on each keyup. Which guarantees value will be more than initialized before its used.

    $.each(editables,function(i){
        current  = $(editables[i]);
        var value; 
        var currentTextField = $('#theInput'); //should be relational to the editable, not a straight selection query as shown here             
        currentTextField.on('keyup', function(){
            value = currentTextField.val();
            console.log( value );
            current.html( value );
        });
    
    });
    

    assuming editables are regions in which you wish to display the outcome of the text field. The current editable is not the text field itself and will not respond to keyup or .val()

    OR

    If editables are actually the text fields themselves, then they have no interior and you cannot use .html() on them. Nor should you want to. So assuming you DO with to output the result on the page somewhere.

    $.each(editables,function(i){
        current  = $(editables[i]);
        var value; 
        var currentTextField = $('#outPutLocation'); //should be relational to the editable, not a straight selection query as shown here             
        current.on('keyup', function(){
            value = current.val();
            console.log( value );
            currentTextField.html( value );
        });     
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a bunch of posts stored in text files formatted in yaml/textile (from
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.