Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Textarea not getting updated text in jQuery

So I have a razor view:

@{
    int i=1;
    foreach(var story in Model.Storylines)
    {
        <span style="float:left;">Storyline @i</span> <span style="float:right; margin-right:5px;">Character Count: @story.CharCount</span><br /><br />
        <textarea id=@("entry"+@i) rows="5" style="width:730px; overflow:auto;">@story.Description</textarea><br /><br />
        i++;
    }
}

So the textarea with id entry1 has a description like "this is a story" when the page initially loads. Once I type something into that text area, and then hit a button whose only function is:

alert($("#entry1").text());

I still get "this is a story". Why isn't the textarea being updated with the text that I've typed in?

like image 295
Jay Sun Avatar asked Aug 25 '11 15:08

Jay Sun


1 Answers

You want to use $("#entry1").val() to get the text within the textarea.

like image 126
Joel Etherton Avatar answered Nov 15 '22 21:11

Joel Etherton