I have a table that has been generated dynamically using PHP. The table has a few textfields which are being used to update the database based on the row. This question can be referred at: Complete question, based on one for the answer i am using javascript which gets the textfield value when enter is pressed. The javascript being used is:
$("#details input").live('keypress', function (e) {
var code = (e.keyCode ? e.keyCode : e.which);
if (code == 13) {
e.preventDefault();
var ourId = $(this).id;
var updatedText = $(this).val;
alert(updatedText);
}
});
However for some reason $(this) isn’t returning the expected result.
Any help will be appreciated, thanks.
You’re mixing concepts there.
$(this).id --> this.id OR $(this).attr('id')and$(this).val --> $(this).val(). Instead oflive()which is deprecated, useon()for delegation.