Dave_Williams Dave_Williams - 3 months ago 21
Javascript Question

How to change character in textarea value?

So, say I have a textarea.

<textarea id="area">Test text</textarea>

How can I search for a specific string (For example, "text") and remove it?

I tried this, but to no avail.

document.getElementById("area").replace('text', '');

Any and all help is appreciated!


Simple and easy JavaScript fix:

var area = document.getElementById("area");
area.value = area.value.replace('search', 'string');

This should work with your original TextArea:

<textarea id="area">Test text</textarea>