JavaScript to achieve the click of the button font zoom in and out

  • 2021-01-11 01:52:45
  • OfStack

This article to share js to achieve the click button font zoom in and out of the example code, the code is simple to understand, the need for a friend to refer to it

The specific code is as follows:

.chapter {font-size: 1.5em;}
$(document).ready(function() {
// $('div.large').addClass('chapter'); 
//$('#switcher').click(function(){// Click the button to add (remove) styles ( toggleClass Methods) 
//$('#switcher button').toggleClass('hidden');
// Zooming in and out of font 
var $biger = $('div.large');
var num = parseFloat($biger.css('fontSize')); 
<div id="switcher" class="switcher">
<h3>Style Switcher</h3>
<button id="switcher-default"> Default </button>
<button id="switcher-hidden">Narrow hidden</button>
<button id="switcher-large">Large Print</button>
<button id="switcher-bigger">switcher-bigger</button>
<button id="switcher-small">switcher-small</button>
<div class="large">
<p> The home of the script </p>
<p> The home of the script </p>
<p> The home of the script </p>
<p> The home of the script </p>

JavaScript on the realization of click the button font enlargement, reduction of the relevant knowledge to introduce so much, I hope to help you!

Related articles: