So say I have some colors:
Red
Blue
Blue
Green
I want to put only the unique ones into an array. Then, I want each item in that array to be added to a list of colors that already exists. So my final result would be something like:
<ul>
<li>Original Color</li>
<li>Original Color</li>
<li>Red</li>
<li>Blue</li>
<li>Green</li>
</ul>
I got as far as putting the colors into an array, and then finding the unique ones. But I am lost from there.
Okay, here is what I have so far:
var yearArray = [];
$('#calendar .item').each(function(){
var dataYear = $(this).attr('data-year');
yearArray.push(dataYear);
});
yearArray = $.unique(yearArray);
I was afraid to post that because I don't know if it makes any sense, especially with my example. I'm really getting a list of years and need to put only 1 of each year into a ul, in order to paginate a calendar. I have my unique list of years, but I dont know what to do with it now.