I've tried a couple things like document.title
and also giving the title tag and id and pulling the innerHTML
.
<script>document.getElementByID('tr').innerHTML="";</script>
There's got to be a simpler way to do this and I'm just forgetting and can't figure it out atm.
my title tags are normal
<title></title>
or should i use the
<title id="tr"></title>
Any help would be greatly appreciated. Thank you.
You are correct that you can get the title tag content by
document.title
//or
document.querySelectorAll('title')[0].innerHTML;
But I'm not sure where you want to put it. You are grabbing a element now, but probably want to put it somewhere else;
In your HTML:
<h3 id='title'> </h3>
In your JavaScript
var title = document.title;
var domElem = document.getElementById('title');
//Add title to DOM element
domElem.innerHTML = title;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.