JavaScript bold method
ThelastIndexOf method returns a bold string defined using the HTML b tag. Its syntax is as follows:
Tip: This method does not comply with ECMA standards and is not recommended.
bold method instance
Run this example, output:
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
function changFont( x ){
var font_style = x;
var article = document.getElementById("article");
If( typeof font_style == "string" ){
article.style.fontWeight = font_style;
} else {
article.style.fontSize = font_style;
}
}
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.