Introduction
Here
I will explain how to select all the text by click on textarea or textfield using
JavaScript or Highlight All Text by Clicking on Text Field
or Textarea in JavaScript.
Description:
In
previous article I explained how to set watermark text for textbox using
JavaScript,
Remove duplicate values from string
array in JavaScript, Disable drag and drop options in
textbox or textarea controls, JavaScript show number of characters
left in textbox and many articles relating to asp.net, jQuery, JavaScript. Now I will explain
how to select all the text by click on textarea or textbox field using JavaScript.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Javascript onclick select all textarea</title>
<script type="text/javascript">
function SelectAll(id) {
document.getElementById(id).focus();
document.getElementById(id).select();
}
</script>
</head>
<body>
<div>
Enter Text:<br/>
<input type="text" id="txtfld" onclick="SelectAll('txtfld');" style="width:200px" value = "This text you can select all" /><br />
Textarea:<br/>
<textarea rows="5" cols="23" id="txtarea" onclick="SelectAll('txtarea');" style="width:200px" >Hi, Welcome to Aspdotnet-Suresh.com. I hope
this site will give you better info </textarea>
</div>
</body>
</html>
|
Live Demo
To check for live demo try to put cursor in below textbox or textarea
Textbox:
Textarea: |
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
2 comments :
Very Good Articles......I like So Much....Very Helping to us
it is not working in gridview textbox
please help
thankQ
Note: Only a member of this blog may post a comment.