I need help to grab information from a textarea. When I click on a link named "Edit", the div beside it containing a note, is transformed from a div to a textarea.
I do this with the following code:
$(".edit").click( function(){
var id = parseInt($(this).attr('id').split('_')[1]); //returns the unique integer
//edit only the div with that integer assigned
$('#edit_note_'+id).replaceWith(function() {
return $("<textarea name='anteckning' style='width: 550px; height: 350px;'>").text(this.textContent);
});
$('.show_edit_button_'+id).show();
});
After I have finished editing the note, I want to upload it to the database. But I don't know how to grab the edited text in the textarea? I've tried .text()
, but when I use it, it is declares as undefined.
Anyone who can help me?