Created
August 11, 2016 11:31
-
-
Save obojdi/f73cd424b6e67878d79dd96c7aef3f9d to your computer and use it in GitHub Desktop.
Пепячиватель текста
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//подставить в el DOM-селектор попячиваемого элемента | |
function pepyachka(el) { | |
if (typeof window.jQuery == "undefined") { | |
var g = document.createElement('script'); | |
g.type = "text/javascript"; | |
g.src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"; | |
document.head.appendChild(g); | |
} | |
var | |
a = document.createElement('link'), | |
b = jQuery(el).text(), | |
c = b.split("") | |
a.rel = 'stylesheet'; | |
a.href = 'http://pepyaka.su/css/pepyaka-font.css'; | |
document.head.appendChild(a); | |
jQuery(el).text('') | |
for (var l in c) { | |
jQuery('<span class="pepka pep' + Math.floor(Math.random() * c.length) + '">' + c[l] + '</span>').appendTo(jQuery(el)); | |
} | |
jQuery('.pepka').wrapAll('<div class="pepyaka"/>') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment