Get the App
SLTechnology News&Howtos  ›  Development  › 

How jquery modifies title values

Shulou Source: shulou.com Published: 2022-05-31 18:36:07 09月14日 Update

Most people do not understand the knowledge points of this article "jquery how to modify title value", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "jquery how to modify title value" article.

Jquery modify title value method: 1, using text (), you can modify the title tag value, syntax "$(" title "). Text (" new value ");"; 2, using attr (), you can modify the title attribute value, syntax "element .attr (" title "," new value ");".

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

In HTML, there are two types of title values:

Content value of the title tag

The property value of the title attribute

So how to use jquery to modify these two title values, let's introduce it to you.

1. Jquery modifies the title tag value

Tags define the title of the document and are required in all HTML documents.

Elements:

Define the title in the browser toolbar

Provide the title when the page is added to favorites

The page title displayed in the search engine results

You can use the text () method to modify the value of the title tag. The text () method returns the text content of the selected element.

Example:

The old title of the document $(document) .ready (function () {$("button") .click (function () {$("title") .ready ("New document title") });}); modify the title document title

2. Jquery modifies the value of title attribute

The title attribute specifies additional information about the element.

This information usually displays a tooltip text (tooltip text) when you mouse over the element.

You can use the attr () method to modify the value of the title property, which sets the value of the specified attribute of the selected element.

$(document) .ready (function () {$("button") .click (function () {$("div"). Attr ("title", "new title value");}) This is a test text.

Modify the title attribute of an element

The above is about the content of this article on "how to modify the title value of jquery". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Tags: Attributes elements content titles documents methods tags text information tools articles knowledge articles grammar pages values most that is toolbars often Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Redmi Shulou Tech Info NVidia Huawei