EN
jQuery - how to make focus on textarea element?
14 points
Quick solution:
xxxxxxxxxx
1
$('#my-input').focus();
xxxxxxxxxx
1
2
<html>
3
<head>
4
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
5
</head>
6
<body>
7
<textarea id="my-input" cols="30" rows="4">This is example text...</textarea>
8
<br />
9
<button onclick="makeFocus()">Click me and make focus on textarea</button>
10
<script>
11
12
var input = $('#my-input');
13
14
function makeFocus() {
15
input.focus();
16
}
17
18
</script>
19
</body>
20
</html>