I have a textarea, I would like to trim the text inside it and display the result.
Example:
" 1234 "
becomes
"1234"
However for some reason it doesn't trim the text, and it returns nothing.
HTML
<form id="form1">
<textarea id="text-area" rows="20" cols="50" placeholder="text here..."></textarea><br>
<button class="button" onclick="myFunc()">Sumbit</button>
</form>
JS
function myFunc(){
var getText = document.getElementById("text-area").textContent;
var result = getText;
result.trim();
document.getElementById("text-area").textContent = result;
}
No JQuery please