When I click on my button I am trying to create a bootstrap label. But each time I click it should start off at label-default and work through the switch until it gets to the last one the go back to the beginning
As shown on image below it not starting off at label-default
Question each time I click on the button to create label how can I make sure it does not double up and starts from label-default
DEMO
SCRIPT
$(document).on('click', '#category_button', function(e){
e.preventDefault();
//if ($("#label-" + category_name).length == 0) {
var rand = Math.floor((Math.random() * 5) + 1);
switch(rand){
case 1:
element = 'label-default';
break;
case 2:
element = 'label-primary';
break;
case 3:
element = 'label-success';
break;
case 4:
element = 'label-info';
break;
case 5:
element = 'label-warning';
break;
}
html = '';
html += '<li id="">';
html += '<span class="label ' + element + '">';
html += 'Hello';
html += '</span>';
html += '</li>';
$('.categories ul').append(html);
//}
});