【发布时间】:2014-04-05 20:22:17
【问题描述】:
谁能帮我将我的文本动画添加到我创建的表单中?
当您刷新页面时,文本当前会显示动画,虽然我需要它像表单中的占位符一样工作,但效果很好。
一旦用户点击表单,文本需要消失,以便用户能够正常搜索。
请看我的Fiddle
如果有人可以提供帮助,请更新小提琴,非常感谢您的帮助!
var txt = $('.writer').text();
var timeOut;
var txtLen = txt.length;
var char = 0;
$('.writer').text('|');
(function typeIt() {
var humanize = Math.round(Math.random() * (200 - 30)) + 30;
timeOut = setTimeout(function() {
char++;
var type = txt.substring(0, char);
$('.writer').text(type + '|');
typeIt();
if (char == txtLen) {
$('.writer').text($('.writer').text().slice(0, -1)); // remove the '|'
clearTimeout(timeOut);
}
}, humanize);
}());
【问题讨论】:
-
你的意思是占位符文本应该是动画的?并在用户点击后删除?
-
是的,这正是我的意思?
标签: jquery html forms animation placeholder