Literally blow text apart from random places using jQuery

There are several jQuery examples of how to untie text, like this one:

http://jsfiddle.net/doktormolle/dNXVx/

How to do the opposite?

I want to explode letters from the span element to random places.

+4
source share
1 answer
function fx(o) { var $o = $(o); $o.html($o.text().replace(/([\S])/g, "<span>$1</span>")); $o.css("position", "relative"); $("span", $o).each(function(i) { var newTop = Math.floor(Math.random()*500)*((i%2)?1:-1); var newLeft = Math.floor(Math.random()*500)*((i%2)?1:-1); $(this).css({position: "relative", opacity: 1, fontSize: 12, top: 0, left: 0 }).animate({ opacity: 0, fontSize: 84, top: newTop, left:newLeft },1000); }); }​ 

You can see the code in action http://jsfiddle.net/dNXVx/37/

+7
source

Source: https://habr.com/ru/post/1400850/


All Articles