In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "js how to set html title title", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "js how to set html title title" this article.
Methods: 1, use "document.getElementsByTagName (" title ") [0] .innerText = 'value'" statement; 2, use "document.title=' value" statement; 3, use "$('title'). Html (' value')" statement.
The operating environment of this tutorial: windows7 system, javascript1.8.5&&jquery1.10.2 version, Dell G3 computer.
InnerText mode
Through console.log (document.getElementsByTagName ("title") [0]), it is found that the label can be printed, and there are only text nodes in the label, so it can only be guessed that TextNode can be identified, so setting the value of title with innerText is a success.
Document.getElementsByTagName ("title") [0] .innerText = 'value to be set'; document.title mode
After testing, you can also set the value of title through document.title.
Console.log (document.title); # can get the value of title. Document.title = 'value to be set'; # set the value of title.
JQuery mode
JQuery way We change the value of title when the browser gains focus and loses focus, and we can see that title changes when we switch browser tabs.
Of course, if your project depends on jQuery, you can set it using the jq method.
$('title') .html (' value to be set') $('title') .text (' value to be set')
Example:
Hello / / $('title'). Html (''); $('title'). Text ('')
In native js, we can dynamically modify the title of a web page through innerText and document.title.
In jq, we can modify it with $('title'). Html (') or $('title'). Text (').
The above is all the content of the article "how to set the title of html title in js". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.