Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the title attribute in javascript

Shulou Source: shulou.com Published: 2022-06-02 07:24:02 10月05日 Update

This article introduces the knowledge of "how to use the title attribute in javascript". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

In javascript, the title property is used to set or return the title of the current document, that is, the text content in the HTML title element; you can return the title directly using the "document.title" statement, and modify the title using the value "" statement that "document.title=" needs to set.

The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.

In javascript, the title property is used to set or return the title of the current document (the text content in the HTML title element).

Syntax:

Return to the document title

Document.title

Set (modify) document title

Document.title= "value to be set"

Example:

Old document title function my (id) {return document.getElementById (id) } my ("btn1"). Onclick = function () {var title = document.title; alert (title) } my ("btn2") .onclick = function () {document.title = "new document title"; var title = document.title; alert ("modified successfully, the new value is:" + title) }

That's all for the content of "how to use the title attribute in javascript". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Title document attribute content element text more knowledge sentence utility success achievement next dilemma reality situation tutorial article case environment Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Microsoft Shulou Technology Shulou Tech Info MySQL