JS method to modify html title: 1. Use the "document.title="value that needs to be set";" statement; 2. Use "$('title').html('value that needs to be set' )" or "$('title').text('value to be set')" statement.
The operating environment of this tutorial: windows7 system, javascript1.8.5&&jquery1.7.2 version, Dell G3 computer.
Method 1: document.title method
After testing, the value of title can also be set through document.title.
document.title = '需要设置的值';
Example
Method 2: Using jQuery’s html() or text() method
Of course, if your project relies on jQuery, you can use the jq method to set it.
Both methods can be implemented in jq
$('title').html('需要设置的值') $('title').text('需要设置的值')
Example
[Recommended learning:javascript advanced tutorial】
The above is the detailed content of How to modify the title of html in js. For more information, please follow other related articles on the PHP Chinese website!