EN
JavaScript - how to make focus on textarea element?
5 points
Using JavaScript it is possible to get focus on textarea
element in following way.
xxxxxxxxxx
1
2
<html>
3
<body>
4
<textarea id="my-input" cols="30" rows="4">
5
This is example text...
6
</textarea>
7
<br />
8
<button onclick="makeFocus()">Click me and make focus on textarea</button>
9
<script>
10
11
var input = document.getElementById('my-input');
12
13
function makeFocus() {
14
input.focus();
15
}
16
17
</script>
18
</body>
19
</html>
Read this article to see jquery approach.