Change font size using JQuery

Developer
Size
2,084 Kb
Views
10,120

How do I make an change font size using jquery?

What is a change font size using jquery? How do you make a change font size using jquery? This script and codes were developed by James Barnett on 04 January 2023, Wednesday.

Change font size using JQuery Previews

Change font size using JQuery - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Change font size using JQuery</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="container"> <h1>Resize Me</h1> <p class="font-size-label">Font Size</p> <button id="up">+</button> <p id="font-size"></p> <button id="down">-</button>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Change font size using JQuery - Script Codes CSS Codes

body { margin: 20px; }
.container { width: 500px; text-align: center;
}
h1 { height: 60px; padding: 0; margin: 0;
} p { display: inline-block; } .font-size-label { margin-right: 20px; } #font-size { margin: 0 5px; } button { width: 30px; height: 30px; }

Change font size using JQuery - Script Codes JS Codes

// When + or - buttons are clicked the font size of the h1 is increased/decreased by 2
// The max is set to 50px for this demo, the min is set by min font in the user's style sheet
function getSize() { size = $( "h1" ).css( "font-size" ); size = parseInt(size, 10); $( "#font-size" ).text( size );
}
//get inital font size
getSize();
$( "#up" ).on( "click", function() { // parse font size, if less than 50 increase font size if ((size + 2) <= 50) { $( "h1" ).css( "font-size", "+=2" ); $( "#font-size" ).text( size += 2 ); }
});
$( "#down" ).on( "click", function() { if ((size - 2) >= 12) { $( "h1" ).css( "font-size", "-=2" ); $( "#font-size" ).text( size -= 2 ); }
});
Change font size using JQuery - Script Codes
Change font size using JQuery - Script Codes
Home Page Home
Developer James Barnett
Username jamesbarnett
Uploaded January 04, 2023
Rating 3
Size 2,084 Kb
Views 10,120
Do you need developer help for Change font size using JQuery?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

James Barnett (jamesbarnett) Script Codes
Create amazing SEO content with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!