SomeoneS
SomeoneS

Reputation: 1279

Textarea inside div, getting changed value

i have textarea and lot of other HTML elements inside one div, like this:

 <div id="holder">
 <textarea id="txt">Some text</textarea>
 <img src="/someurl/test.png" />
 <div class="test">Blah</div>
 </div>

When i try to get all html inside "holder" div, with code below, it works well. BUT if i change textarea value, and try to get html again, value of textarea is still "Some text", not new text. How to get new, updated text?

Here is how i get html of "holder":

 $("#submit").click(function(){
    alert($("#holder").html() ); 
 });

And here is jsfiddle example:

http://jsfiddle.net/zmL7k/

Upvotes: 1

Views: 998

Answers (1)

Esailija
Esailija

Reputation: 140234

Update the textarea html manually:

$("#submit").click(function() {
    $("#txt").html(function() {
        return this.value;
    });
    alert($("#holder").html());
});​

Upvotes: 4

Related Questions