In this example I will show you how to select text from textarea in javascript. We can select the entire contents of text area using select property.
Example:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="en-us" />
<title>select the text from textarea in Javascript</title>
<style type="text/css">
.btn {
width: 100px;
height: 50px;
background: #00BCD4;
border-style: solid;
border-color: white;
color: white;
}
</style>
<script type="text/javascript">
function OnSelectCode() {
document.getElementById("code").select();
}
</script>
</head>
<body style="width: 500px;">
<h1>select the text from textarea in Javascript</h1>
<table>
<tr>
<td colspan="3" style="color: darkblue;">click on the button to select the text from textarea</td>
</tr>
<tr>
<td colspan="3">
<textarea rows="15" style="width: 400px" id="code">
Linq is very easy to read and simplifies the code. We can filter and List the group of words by string length from a string array.
</textarea></td>
</tr>
<tr>
<td colspan="3">
<input type="button" value="Select Code" class="btn" onclick="OnSelectCode()"></td>
</tr>
</table>
</body>
</html>
Output:
Post your comments / questions
Recent Article
- How to create custom 404 error page in Django?
- Requested setting INSTALLED_APPS, but settings are not configured. You must either define..
- ValueError:All arrays must be of the same length - Python
- Check hostname requires server hostname - SOLVED
- How to restrict access to the page Access only for logged user in Django
- Migration admin.0001_initial is applied before its dependency admin.0001_initial on database default
- Add or change a related_name argument to the definition for 'auth.User.groups' or 'DriverUser.groups'. -Django ERROR
- Addition of two numbers in django python
Related Article