diy
diy

Reputation: 119

Not able to Add more text in text area

I'm trying to add text in a textarea. I think I'm missing some ....my code is below:

$.each(result, function (i, v) {
  if (ui.item.value === v.TextKeyword) {
    if ($('input:radio[name="' + currentid + '"]:checked').val() == 'Append') {
      var cannedtext = $("textarea[parentcontrolid='" + currentid + "']").text() + "," + v.Text;
      $("textarea[parentcontrolid='" + currentid + "']").text(String(cannedtext));
    } else {
      $("textarea[parentcontrolid='" + currentid + "']").text(v.Text);
    }
    $("textarea[parentcontrolid='" + currentid + "']").focus();
  }
});

but when I execute the code it displays this:

enter image description here

enter image description here

Upvotes: 1

Views: 95

Answers (1)

Alex
Alex

Reputation: 8695

You have to use .val() instead of .text().

According to Jquery:

The .text() method cannot be used on form inputs or scripts. To set or get the text value of input or textarea elements, use the .val() method. To get the value of a script element, use the .html() method.

Upvotes: 2

Related Questions