MyBB Community Forums

Full Version: Mutli-Colored text
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
ok i have found this thing while messing around on google and i have been trying to get it to work with what i want it to do but i cant seem to figure it out and figured would post it here and see if someone could help me out

<span id="example">Multi color me</span>

$(document).ready(function() {
  var test = $("#example").text().split('');

    var result = "";
    var i = 0;
    for(i=0; i < test.length; i++) {
        result += "<span style='color:"+getColor()+"'>"+test[i]+"</span>";
    }
    $("#example").html(result);      
});

function getColor() {
    var colList = ['#ff00ee', '#ffffff','#00ff00'];

    var i = Math.floor((Math.random()*colList.length));
  return colList[i];
}
​


so there is that and here is something from jsfiddle

http://jsfiddle.net/DZpyw/49/

and here is this one

http://jsfiddle.net/DZpyw/49/show/

but i cant seem to get it to work

what i am trying to do with it is make it work with the name color of a usergroup
it is working for me
headerinclude template consists of jQuery loading code and below code
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function() {

  var test = jQuery("#groupname").text().split('');
  
    var result = "";
    var i = 0;
    for(i=0; i < test.length; i++) {
        result += "<span style='color:"+getColor()+"'>"+test[i]+"</span>";
    }
    jQuery("#groupname").html(result);      
});
        
function getColor() {
    var colList = ['#00FF00', '#FF0000','#0000FF'];

    var i = Math.floor((Math.random()*colList.length));
  return colList[i];
}
</script>

and administrator group username style is:
<span id="groupname"><strong><em>{username}</em></strong></span>
okies i will look into it thanks for the reply