-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormEvent.html
More file actions
40 lines (40 loc) · 878 Bytes
/
FormEvent.html
File metadata and controls
40 lines (40 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Form Event</title>
<style type = "text/css">
.highline {
border: 3px solid red;
}
.hidden {
display: none;
}
</style>
<script src="jquery-3.2.1.min.js"></script>
<script>
$(document).ready(function() {
$('p').addClass('hidden');
$('#name').focus(function() {
$(this).addClass('highline');
}).blur(function() {
$(this).removeClass('highline');
});
$('#memo').focus(function() {
$('p').addClass('hidden');
}).blur(function() {
var msg = $(this).val();
var numChar = msg.length;
$('#counter').text(numChar);
$('p').removeClass('hidden');
});
});
</script>
</head>
<body>
姓名: <input type="text" id="name"><hr/>
留言:
<textarea id="memo" cols="50" rows="5"></textarea>
<p>字元數: <span id="counter"></span></p>
</body>
</html>