JavaScript – Change the font size of button
In this post we will give you information about JavaScript – Change the font size of button. Hear we will give you detail about JavaScript – Change the font size of buttonAnd how to use it also give you demo for it if it is necessary.
we are going to learn about how to change the font size of a button using JavaScript.
Consider, that we have the following button element in our HTML:
<button id="btn">Login</button>
Now, we want to change the above button font size using JavaScript.
Changing the button font size
To change the font size of a button, first we need to access the button element object inside the JavaScript using the document.getElementById() method.
const btn = document.getElementById("btn");
Now, set its style.fontSize property to your desired size (eg: 10px or 20px or 25px, etc).
btn.style.fontSize = "18px";
It changes the font size of a button element to 18px.
Full example:
<button id="btn">Login</button>
JavaScript:
const btn = document.getElementById("btn");btn.style.fontSize = "18px"; // changes the font size to 18px
Hope this code and post will helped you for implement JavaScript – Change the font size of button. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs