Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't get value from input text on keyup with jquery
    primarykey
    data
    text
    <p>I'm trying to get the value of an <code>&lt;input type=text&gt;</code> with the method keyup from jQuery but whenever i log it it logs undefined.</p> <p>Here is my code:</p> <pre><code>$.each(editables,function(i){ current = $(editables[i]); var value; current.on('keyup', function(){ value = $(this).val(); console.log( value ); }); current.html( value ); }); </code></pre> <p>Thanks in advance</p> <p><strong>EDIT</strong></p> <p>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 <code>&lt;td class="editable"&gt;</code> to an <code>&lt;input type="text"&gt;</code> and i'm trying to get the value from them after i click the button again, i will send the info via <code>$.post()</code> but i can't get the value from these inputs</p> <p><strong>EDIT 2</strong> Here is the full code of the handler hope it helps, thanks to all that have contributed $('.edit').on('click',function(e){</p> <pre><code> $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("&lt;input type='text' value='"+currentValue+"'&gt;&lt;/input&gt;"); }); $this.val('Save'); } e.preventDefault(); }); </code></pre> <p><strong>UPDATE</strong><br/> there was something else wrong in my code outside of the one i shared here that messed up the funcionality. <br /> Thanks to everyone who helped</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload