Home > Web Front-end > JS Tutorial > Getting started with JavaScript bold method (display specified text in bold)_Basic knowledge

Getting started with JavaScript bold method (display specified text in bold)_Basic knowledge

WBOY
Release: 2016-05-16 16:33:37
Original
2083 people have browsed it

JavaScript bold method

The

lastIndexOf method returns a bold string defined using the HTML b tag. Its syntax is as follows:

Copy code The code is as follows:

str_object.bold()

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

bold method instance

Copy code The code is as follows:


Run this example, output:

Copy code The code is as follows:

www.jb51.net

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

Further reading: Changing the font size of page elements

Copy code The code is as follows:



Normal Bold
Small Large



I am some text...

Some Text...




In this example, by controlling the font CSS style through JavaScript, the display font (id="article") can be switched in real time between bold, normal font, small font and large font.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template