-
Notifications
You must be signed in to change notification settings - Fork 1
/
placeholder-animation.html
72 lines (56 loc) · 1.71 KB
/
placeholder-animation.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Input Placehodler Animtaion</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<div class="container">
<h2>Placeholder Animation</h2>
<input type="text" id="quickInq_vniraj" placeholder="[email protected]" class="form-control">
</div>
<script >
var milliseconds = 4000;
placeholder = function(){
this.write_placeholder = function(field, text, n) {
if (n < (text.length)) {
$('#'+field).attr("placeholder", text.substring(0, n+1));
n++;
setTimeout(function() {
var obj = new placeholder();
obj.write_placeholder(field, text, n)
}, 65);
}
}
this.set_fields = function(objFields){
for (var key in objFields) {
// skip loop if the property is from prototype
if (!objFields.hasOwnProperty(key)) continue;
this.write_placeholder(key, objFields[key], 0);
this.intervallize(objFields);
}
}
this.intervallize = function(objFields){
var interval = setInterval(function() {
for (var key in objFields) {
if (!objFields.hasOwnProperty(key)) continue;
var obj = new placeholder();
obj.write_placeholder(key, objFields[key], 0);
}
}, milliseconds);
}
this.interval_time = function(ms){
milliseconds = ms;
}
}
var obj = new placeholder();
obj.interval_time(9000);
setTimeout(function(){ obj.set_fields({
'quickInq_vniraj': '[email protected]',
}, 1000); }, 3000);
</script>
</body>
</html>