Hi everyone, I have a problem that I can not solve. I this I want to change the number of a month by the name of the month type like this: (2/2013 for February / 2013). In the code below I'm making it do list in chronological order by month / year. And I wanted to know how I can now change the number of the month by the name of what corresponds to it.
======= HTML =====
<p>Tarefa colocar em ordem cronológica ( Mes/Ano)</p>
<div class="galeria">
<a href="#122014" data-order="2014-12" rel="12/2014/4">12/2014</a>
<a href="#12015" data-order="2054-01" rel="1/2015/4">1/2015</a>
<a href="#112014" data-order="2014-11" rel="11/2014/4">11/2014</a>
<a href="#102014" data-order="2013-2" rel="2/2013/4">2/2013</a>
</div>
======= JS ======
$(document).ready(function(){
var $sort = $('a');
var $list = $('.galeria');
var $listLi = $('a',$list);
$listLi.sort(function(a, b){
var keyA = $(a).attr('data-order');
var keyB = $(b).attr('data-order');
return (keyA > keyB) ? 1 : 0;
});
$.each($listLi, function(index, row){
$list.append(row);
});
function trocarNomeMes(mes) {
switch ( mes ) {
case 1: mes = "Janeiro";
break;
case 2: mes = "Fevereiro";
break;
case 3: mes = "Março";
break;
case 4: mes = "Abril";
break;
case 5: mes = "Maio";
break;
case 6: mes = "Junho";
break;
case 7: mes = "Julho";
break;
case 8: mes = "Agosto";
break;
case 9: mes = "Setembro";
break;
case 10: mes = "Outubro";
break;
case 11: mes = "Novembro";
break;
case 12: mes = "Dezembro";
break;
}
return mes;
}
});
LINK JSFIDDLE: link
Where am I going wrong ..?!?