S
S
Serj_112018-02-24 23:14:51
JavaScript
Serj_11, 2018-02-24 23:14:51

How to properly loop a function?

jQuery(function($){
$.get("{THEME}/images/sprite.svg", function(data) {
var div = document.createElement("div");
div.innerHTML = new XMLSerializer().serializeToString (data.documentElement);
document.body.insertBefore(div, document.body.childNodes[0]);
});
});

$(document).ready(function(){
$.fn.animate_Text = function() {
var string = this.text();
return this.each(function(){
var $this = $(this);
$this .html(string.replace(/./g, '$&'));
$this.find('span.new').each(function(i, el){
setTimeout(function(){ $(el) .addClass('div_opacity'); }, 60 * i);
});
});
};
$('#example').show();
$('#example').animate_Text();
$('#example').fadeOut(60000);
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2018-02-25
@Serj_11

I'll delete the author's code, as I fix it myself:

jQuery(function($){
  $.get("{THEME}/images/sprite.svg", function(data) {
    var div = document.createElement("div");
    div.innerHTML = new XMLSerializer().serializeToString(data.documentElement);
    document.body.insertBefore(div, document.body.childNodes[0]);
  });
});

$(document).ready(function(){
  $.fn.animate_Text = function() {
    var string = this.text();
    return this.each(function(){
      var $this = $(this);
      $this.html(string.replace(/./g, '$&'));
      $this.find('span.new').each(function(i, el){
        setTimeout(function(){ $(el).addClass('div_opacity'); }, 60 * i);
      });
  });
};
$('#example').show();
$('#example').animate_Text();
$('#example').fadeOut(60000);
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question