Home >Web Front-end >JS Tutorial >Getting started with the JavaScript fontsize method (displaying strings according to the specified size)_Basic knowledge

Getting started with the JavaScript fontsize method (displaying strings according to the specified size)_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 16:33:341284browse

JavaScript fontsize method

The

fontsize method returns a string defining the font size using the size attribute in the HTML font tag. Its syntax is as follows:

Copy code The code is as follows:

str_object.fontsize( size )

Parameter description:

Parameters Description
str_object String (object) to be operated on
size Required. Numbers from 1 to 7, the larger the number, the larger the font. The font size comparison is as follows:
参数 说明
str_object 要操作的字符串(对象)
size 必需。1 到 7 的数字,数字越大字体越大,字体大小对比如下:
1:10px
2:14px
3:16px
4:18px
5:24px
6:32px
7:48px
1:10px 2:14px

3:16px

4:18px

5:24px 6:32px 7:48px

Tip: This method does not comply with ECMA standards and is not recommended.


fontsize method instance

Run this example, output:

Copy code
The code is as follows:

www.jb51.net

Tip: This method returns the string defined using the HTML font size tag, even though this method cannot dynamically change the font size. If you want to dynamically change the font size of an element, you can refer to the following example:


Copy code

The code is as follows:







Normal Large


I am some text...
Some Text...

In this example, the size of the font (id="article") can be dynamically changed by controlling the font CSS style through JavaScript.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Getting started with JavaScript italics method (display string in italics)Next article:Getting started with JavaScript italics method (display string in italics)

Related articles

See more