I'm creating an accessibility bar and it has the options to increase and decrease the font. Here is the code for the buttons:
<button type="button" id="btnAumentar">A+</button>
<button type="button" id="btnDiminuir">A/</button>
And the jquery code.
var $btnAumentar = $("#btnAumentar");
var $btnDiminuir = $("#btnDiminuir");
var $elemento = $("body .content-center").find("*"); //encontra todos os elementos dentro do #content
var fonts = [];
function obterTamanhoFonte() {
for (var i = 0; i < $elemento.length; i++) {
fonts.push(parseFloat($elemento.eq(i).css('font-size')));
}
}
obterTamanhoFonte();
$btnAumentar.on('click', function() {
for (var i = 0; i < $elemento.length; i++) {
++fonts[i];
$elemento.eq(i).css('font-size', fonts[i]);
}
});
$btnDiminuir.on('click', function() {
for (var i = 0; i < $elemento.length; i++) {
--fonts[i];
$elemento.eq(i).css('font-size', fonts[i]);
}
});
However, you can increase fonts as much as you want, and decrease them. I would like to limit these by clicking on 3, but that they are relative to each other, with a total of 6 font sizes, if it is at max size you can press to decrease 6x for example and vice versa. Can someone help me? =)