how to put different colors in a title with jquery array

0

I would like to put different colors in title with a jQuery array, More without being random, in case they are pre-defined colors I am now starting to program, and would like the help of vcs. right now Obridago

And this is what I want to do the same as the picture below

    
asked by anonymous 10.09.2017 / 02:00

1 answer

0

As HudsonPH said it would be best to use css as a solution, but if you need to manipulate an array that you already know with jquery, try the following:

var cores = ['red', 'yellow', 'gray', 'orange', 'blue', 'red', 'yellow']

AddColors(cores);

function AddColors(cores){
  jQuery.each( cores, function( i, val ) {
    $(".container").append("<div id='"+i+"'>Bla bla bla</div>");
    $( "#" + i ).css("color", val);
  });
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divclass="container">
  
</div>
    
11.09.2017 / 13:40