Show DevBest Christmas Text

Weasel

👄 I'd intercept me
Nov 25, 2011
4,132
2,457
So this script is an improved version of the one @RastaLulz uses on DevBest for the christmas style usernames.

Code:
$.fn.christmas = function() {
  $(this).each(function() {
    $(this).html($(this).text().split("").map(function(v, i) {
      return '<span class="christmas-' + (i % 2 == 0 ? 'red' : 'green') + '">' + v + '</span>';
    }).join(""));
  });
};

$(document).ready(function() {
$(function() {
  $('p.christmas').christmas();
});
});

Code:
.christmas-green {
    color: #008000;
}

.christmas-red {
    color: #D81E1E;
}

You can define the selector of the elements you want to change the text to christmas style in the function call (currently p.christmas).

Enjoy!
 

Users who are viewing this thread

Top