Home > Web Front-end > JS Tutorial > body text

How to make font color change with jquery

coldplay.xixi
Release: 2020-12-22 16:06:43
Original
5082 people have browsed it

How to change the font color in jquery: First use a tag to create a line of text; then in js, use the [css()] method to set the color attribute to change the color of the text.

How to make font color change with jquery

The operating environment of this tutorial: windows7 system, jquery3.2.1 version. This method is suitable for all brands of computers.

How to change the font color with jquery:

1. Create a new html file and name it test.html to explain how jquery changes the text color.

How to make font color change with jquery

2. In the test.html file, use the p tag to create a line of text for testing.

How to make font color change with jquery

3. In the test.html file, set the id of the p tag to mytxt, which is mainly used to obtain the p tag object through this id below.

How to make font color change with jquery

4. In the test.html file, create a button button, bind the onclick click event to the button, and when the button is clicked, execute editshe() function.

How to make font color change with jquery

5. In the js tag, create the editshe() function. Within the function, obtain the p tag object through the id, and use the css() method to change the color attribute of the p tag. , that is, changing the color of the text. For example, let the color of the p tag content be red.

How to make font color change with jquery

#6. Open the test.html file in the browser, click the button to see the effect.

How to make font color change with jquery

Related free learning recommendations: javascript (video)

The above is the detailed content of How to make font color change with jquery. For more information, please follow other related articles on the PHP Chinese website!

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