Created
May 27, 2015 14:16
-
-
Save AlphaNerd/5609d16937c474f03217 to your computer and use it in GitHub Desktop.
Basic jQuery function to split Joomla tittles into multiple <span>. Used for multi-colored titles in Joomla where first word is different color than rest. Simply supply selector, and adjust phrase split.
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
jQuery('.home #bottom_in h3').each(function(i,val){ | |
var titleWords = val.innerHTML.split(" "); | |
var first = titleWords[0] + " "; | |
var second = ""; | |
if (titleWords.length > 2){ | |
for (i=1;i<titleWords.length;i++){ | |
second += titleWords[i]+" "; | |
} | |
}else{ | |
second = titleWords[1]; | |
} | |
jQuery(this).html(""); | |
jQuery(this).html("<span class='firstWord'>"+first+"</span><span class='secondWords'>"+second+"</span>"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment