Javascript – textarea and text input select all

Javascript object.select() can bse used to select full text in textarea and text put fields in HTML.

Example – select all in textarea

<textarea id=id1>Text inside textarea</textarea><br>
<button type="button" onclick="selectAll()">SelectAll</button>

<script type="text/javascript">
function selectAll() {
 var obj = document.getElementById("id1");
  obj.select();
}
</script>
refresh

Example – select all in text input

<input type=text id=id1 value="Text inside text input"><br>
<button type="button" onclick="selectAll()">SelectAll</button>

<script type="text/javascript">
function selectAll() {
 var obj = document.getElementById("id1");
  obj.select();
}
</script>
refresh
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments