get text from textarea javascript code example
Example 1: capture textarea value
<textarea id="myTextarea">
Hello World
</textarea>
<script>
var x = document.getElementById("myTextarea").value;
</script>
Example 2: select all text in textarea javascript
<textarea onclick="this.focus();this.select()"></textarea>
<!-- To copy the text -->
<textarea onclick="this.focus();this.select();document.execCommand('copy')"></textarea>
Example 3: hi;ight word in textarea javascript
$(function(){
$("#search").click(function(){
var area = $('#test');
var findWord = "rhoncus";
var index = area.val().indexOf(findWord);
area.focus().prop({'selectionStart': index, 'selectionEnd': index+findWord.length})
})
})
Example 4: javascript find textarea
if(document.getElementsByTagName('textarea').length > 0) {
}