The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> Trying to create a button to change font size, Trying to create a button to change my font size using html and js
markee
post Nov 1 2021, 11:09 PM
Post #1





Group: Members
Posts: 4
Joined: 4-October 21
Member No.: 28,131



Hi, I'm not sure if I'm posting this in the correct place. I am trying to create a button that allows a user to increase the font size and decrease the font size of a page. I'm am doing this with an HTML page and a javascript page, which I have never done before.

This is what I have at the beginning of the body section on my HTML page:

<section>
<p class=''>Change the font size below</p>
<button class="increase">+</button>
<button class="decrease">-</button>
</section>


I also have this at the end of my body section:

<script src="main.js"></script>



This is what my entire javascript page consists of:

$(document).ready(function () {

var changing_font_size = new Array(".change");

changing_font_size = changing_font_size.join(",");

$(".decrease").click(function () {

let originalFontSize = $(changing_font_size).css("font-size");

let changed_sized = parseFloat(originalFontSize, 10) - 0.8;

$(changing_font_size).css("font-size", changed_sized);

});

$(".increase").click(function () {

let originalFontSize = $(changing_font_size).css("font-size");

let changed_sized = parseFloat(originalFontSize, 10) + 0.8;

$(changing_font_size).css("font-size", changed_sized);

});

});



If anyone knows why nothing happens when I click these buttons please help sad.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 7th June 2024 - 08:26 AM