[英]Get content of a <title> element in html using JavaScript
I have a html page and i have it something like 我有一个html页面,我有类似的东西
<title>this is very cool!</title>
i would like to write a javascript function to retrieve the text in between the <Title>
tags. 我想编写一个JavaScript函数来检索
<Title>
标记之间的文本。 I'm familiar with getElementById
and getElementsByName
, is there something I've missed? 我熟悉
getElementById
和getElementsByName
,我错过了什么吗?
thanks! 谢谢!
您可以通过全局document
属性访问它: document.title
您可以使用getElementsByTagName()
函数获取元素文本属性,请尝试使用
document.getElementsByTagName("title")[0].text
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.