【发布时间】:2018-09-14 16:18:57
【问题描述】:
我有一个将内容复制到另一个 div 的文本区域。不过,那个 div 有带动画的文本。当我开始在 textarea 上书写并开始复制到 div 时,动画停止。如何为每个字符输入应用动画?动画通过类名应用到 div。 HTML:
var $tlt = $('.tlt').textillate({
in: {
effect: 'fadeIn',
shuffle: true
},
out: {
effect: 'fadeOut',
shuffle: true
},
loop: true,
minDisplayTime: 1000,
});
$('.content:not(.focus)').keyup(function() {
var value = $(this).val();
var contentAttr = $(this).attr('name');
$('.' + contentAttr + '').html(value.replace(/\r?\n/g, '<br/>'));
})
$(".manifestoWriter").on('change', '#toChange', function(){
$tlt.textillate('start');
});
<textarea id="manifestoWriter" class="chatinput form-control content" placeholder="We want courage, audacity and hope without the fascism" rows="11" style="resize: none; background-color:#f7f7f7; border: 0cm; border-radius: 0cm; " maxlength="800" name="mas"></textarea>
<h1 class="tlt mas" id="toChange">
We want courage, audacity and hope without the fascism
</h1>
【问题讨论】:
-
你的代码没有运行,因为你没有包含 JQuery 和任何扩展
textillate来自 -
@zfrisch 很抱歉,jsfiddle 现在可以工作了。
标签: javascript html textarea