-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
50 lines (47 loc) · 1.17 KB
/
demo.html
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
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>jQuery.modify</title>
</head>
<body>
<h1>jQuery.modify</h1>
<form action="#">
<div>
<input type="text" name="text" autofocus="autofocus" value="jQuery modify test" />
</div>
<div>
<input type="password" name="password" value="jQuery modify test" />
</div>
<div>
<textarea name="textarea">jQuery modify test</textarea>
</div>
<div>
<select name="select">
<option value="jQuery">jQuery</option>
<option value="modify">modify</option>
<option value="test">test</option>
</select>
</div>
</form>
<!-- log area -->
<div id="log"></div>
<script src="https://code.jquery.com/jquery-1.7.0.min.js"></script>
<!-- That's it! Now you can trap "modify" event! -->
<script src="./jquery.modify.min.js"></script>
<script>
(function($, window, undefined)
{
$(function($)
{
$(window.document).on("modify", ":input", function(event, data)
{
// Look!
var message = $(this).attr("name") + ": " + data.previousValue + " -> " + data.currentValue;
$("<div />").text(message).prependTo($("#log"));
});
});
})(jQuery, window);
</script>
</body>
</html>