Reputation: 119
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:
Upvotes: 1
Views: 95
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