1
Good morning,
I am using this code to increase and decrease the font, I wanted to know how I can do so when click a third button (A) it return to the standard size of the font, also need to lock and allow click the button increase and decrease only 3 times.
var $btnAumentar = $("#btnAumentar");
var $btnReset = $("#btnAumentar");
var $btnDiminuir = $("#btnDiminuir");
var $elemento = $("body").find("*");
var fonts = [];
console.log($btnAumentar);
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]);
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<body>
<div class="text-right myContainer d-print-none d-none d-lg-block">
<button class="btn btn-primary mr-2 mt-2" type="button" id="btnDiminuir">A-</button>
<button class="btn btn-primary mr-2 mt-2 normal" type="button" id="btnReset">A</button>
<button class="btn btn-primary mr-2 mt-2" type="button" id="btnAumentar">A+</button>
</div>
<div class="banner-conteudo_txt">
<h1 data-aos="fade-up-right" class="titulo-web-aulas cor-fundo aos-init aos-animate" tabindex="6">Tema base
</h1>
<h2 data-aos="fade" class="tx-branco mb-4 mt-2 subtitulo-web-aulas aos-init aos-animate" tabindex="7">Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</h2>
<p data-aos="fade" class="descricao-web-aulas mt-0 aos-init aos-animate" tabindex="8">Unidade 0 - Seção 0</p>
</div>
</body>
I believe there are two variables pointing to the same button.
– Máttheus Spoo