Displayed on the page below is a list of usernames in a random order. I'm looking to sort them using jQuery in the following sequence:
red blue green purple black
This is my current progress:
<script type="text/javascript">
$(function() {
var admin = "rgb(255, 0, 0)";
var moderator = "rgb(00, 00, 255)";
var text = "rgb(00, 128, 00)";
var vip = "rgb(128, 00, 128)";
var adminBuffer = [];
var moderatorBuffer = [];
var textBuffer = [];
var vipBuffer = [];
var html;
$("div#active_users span.name").each(function(i) {
color = $("a span",this).css("color");
html = $(this).html();
if(admin == color){
adminBuffer[i] = "<span class='name'>" + html + "</span>";
}
//$(this).clone().append(" ").appendTo('#rezultat');
});
jQuery.each(adminBuffer, function() {
//alert(this);
$(this).appendTo("#rezultat");
});
});
</script>
I have successfully identified the red username but am encountering difficulties appending it to another element with an ID of "rezultat".
Any suggestions or ideas are appreciated!