あなたは、TxtRotateを再利用入力のプレースホルダプロパティを変更し、テキストにキャレット効果を追加することができ、このバージョン
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Raleway:200,100,400" rel="stylesheet" type="text/css" />
<meta charset="ISO-8859-1">
<title>Insert title here</title>
<script>
var TxtRotate = function(el, toRotate, period) {
this.toRotate = toRotate;
this.el = el;
this.loopNum = 0;
this.period = parseInt(period, 10) || 2000;
this.txt = '';
this.tick();
this.isDeleting = false;
};
TxtRotate.prototype.tick = function() {
var i = this.loopNum % this.toRotate.length;
var fullTxt = this.toRotate[i];
if (this.isDeleting) {
this.txt = fullTxt.substring(0, this.txt.length - 1);
} else {
this.txt = fullTxt.substring(0, this.txt.length + 1);
}
this.el.value =this.txt;
var that = this;
var delta = 300 - Math.random() * 100;
if (this.isDeleting) { delta /= 2; }
if (!this.isDeleting && this.txt === fullTxt) {
delta = this.period;
this.isDeleting = true;
} else if (this.isDeleting && this.txt === '') {
this.isDeleting = false;
this.loopNum++;
delta = 500;
}
setTimeout(function() {
that.tick();
}, delta);
};
window.onload = function() {
var element = document.getElementById('myInput');
var toRotate = element.getAttribute('data-rotate');
var period = element.getAttribute('data-period');
new TxtRotate(element, JSON.parse(toRotate), period);
}
</script>
</head>
<body>
<div class="form-group">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<center><label class="heypal-label"><span id="heypal">HeyPal<span class="gray-lighter">.me/</span></span></label>
<input id="myInput" type="text" class="form-control conference-input"
data-period="2000"
data-rotate='[ "nerdy.", "simple.", "pure JS.", "pretty.", "fun!" ]'>
<button type="submit" class="btn btn-lg btn-danger btn-autosize">Go!</button></center>
</div>
</div>
</body>
</html>
おかげではなく、スニペットにタイピングカルーセルは、プレースホルダ –
おっと、私はあなたが望んで実現しなかったではありません。私は私の答えを更新しました。 –