Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change FontSize By JavaScript?

This code is not working

var span = document.getElementById("span"); span.style.fontsize = "25px"; span.innerHTML = "String"; 


like image 479
jams Avatar asked Apr 07 '11 19:04

jams


People also ask

How do you change the font of text in JavaScript?

In the javascript function, here changeFontStyle(), the fontFamily property value is set to the font value of the option selected. By default, it is set to Times New Roman. Output: Before selecting any option (Initial value – Times New Roman):

How do I change the text size in a div?

To change the font size of a div using JavaScript, get reference to the div element, and assign required font size value to the element. style. fontSize property.


1 Answers

JavaScript is case sensitive.

So, if you want to change the font size, you have to go:

span.style.fontSize = "25px"; 
like image 57
ambiguousmouse Avatar answered Oct 14 '22 00:10

ambiguousmouse