Titulos al estilo Alejandro con jQuery

Este mini-plugin va en honor a Alejandro Adriasola amo y señor de las páginas web y el diseño.

Lo que hace es bien sencillo, toma un texto y lo junta envolviendolo con spans alternando las clases para obtener un lindo resultado si se usa con un css adecuado.

/* Copyright (c) 2009 José Joaquí­n Núñez (josejnv@gmail.com) http://joaquinnunez.cl/blog/
 * Licensed under CBSDLLIAT (http://twitter.com/joaquin_nunez/status/1852053223636992)
 *
 * Version : 0.1
 *
 * Requires: jQuery 1.4+
 */

(function($)
{
  jQuery.fn.AlejandroTitle = function(options)
  {
    var defaults = {
      firstClass:  ‘green’,
      secondClass: ‘gray’
    };

    var opts = $.extend(defaults, options);

    this.each(function(){
      var title = jQuery(this).html();
      var words = title.split(‘ ‘);
      var newTitle = ;
      jQuery(words).each(function(index, word){
        cssClass = index % 2 == 0 ? defaults.firstClass : defaults.secondClass;
        newTitle += ‘<span class="’+cssClass+‘">’ + word + ‘</span>’;
      });
      jQuery(this).html(newTitle);
    });
  }
})(jQuery);

2 Responses to “Titulos al estilo Alejandro con jQuery”

  1. <a href='http://www.ampliamente.cl' rel='external nofollow' class='url'>Rola</a>Rola

    1:48 pm
    May 20th, 2011

    Y el resultado?

  2. <a href='http://e' rel='external nofollow' class='url'>q</a>q

    7:51 pm
    January 12th, 2012

    asd

 

Leave a Reply