jquerytextarea

Set value of textarea in jQuery


I am attempting to set a value in a textarea field using jquery with the following code:

$("textarea#ExampleMessage").attr("value", result.exampleMessage);

The issue is, once this code executes, it is not altering the text in the textarea?

However when performing an alert($("textarea#ExampleMessage").attr("value")) the newly set value is returned?


Solution

  • Have you tried val?

    $("textarea#ExampleMessage").val(result.exampleMessage);