Get the App
SLTechnology News&Howtos  ›  Development  › 

How to change the font to Song style by jquery

Shulou Source: shulou.com Published: 2022-05-31 20:35:59 10月04日 Update

This article mainly explains "how jquery changes the font to Song style". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to change the font to Song style by jquery.

Modification methods: 1, use css () to control font-family style, syntax "text element .css (" font-family "," Song style "); 2, use attr () to set font style, syntax" text element .attr ("style", "font-family:' Arial'") ".

The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.

In a browser, parse an html document whose text has a default font.

Method 1: use css ()

The css () method returns or sets one or more style properties of the matching element.

You just need to use the css () method to set the font-family property and set the property value to "Arial".

Example:

$(document) .ready (function () {$("button") .click (function () {$("# zt"). Css ("font-family", "Arial");})

Default font

Modify font

Change the font to Song style

Method 2: using attr () method

The attr () method sets or returns the property value of the selected element.

You can use this method to set the style property and add font-family: "Song style"; style.

Example:

$(document) .ready (function () {$("button") .click (function () {$("p"). Attr ("style", "font-family:' Arial'");})

This is a passage.

This is a passage.

Change the font to Song style

Description:

The font-family attribute specifies the font of an element.

The font-family property should set several font names as a "backup" mechanism, and if the browser does not support the first font, it will try the next font.

Note: if the name of the font family is more than one word, it must be in quotation marks, such as Font Family: "Arial".

The property value of this property:

Value description

Family-name

Generic-family

A priority list of font family names or / and class family names used for an element.

Default value: depends on the browser.

Inherit states that font families should be inherited from the parent element. At this point, I believe you have a deeper understanding of "how jquery changes the font to Song style". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Font Arial properties methods elements text name style browser browsing content examples grammar this is learning practical deeper interest depending on multiple Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Information MariaDB Xiaomi NVidia