# How to change text content of Title tag using DOM?

**URL:** <https://forum.kirupa.com/t/how-to-change-text-content-of-title-tag-using-dom/237887>\
**Category:** web dev\
**Created:** [September 5, 2007, 4:47am UTC](https://forum.kirupa.com/t/how-to-change-text-content-of-title-tag-using-dom/237887 "2007-09-05T04:47:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![prost](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@prost](https://forum.kirupa.com/u/prost)\
**Post date:** [September 5, 2007, 4:47am UTC](https://forum.kirupa.com/t/how-to-change-text-content-of-title-tag-using-dom/237887/1 "2007-09-05T04:47:55Z")

</div>

Hi!  
I have a title tag:  
\<TITLE\>Title - Old\</TITLE\>  
I want to change it to:  
\<TITLE\>Title - New\</TITLE\>

I tried the following:  
\<BODY\>  
\<SCRIPT\>  
var DocTitle = document.getElementsByTagName(“title”)[0];  
alert(DocTitle.nodeValue);  
\</SCRIPT\>  
\</BODY\>

The alert box gives a message “null”(IE). Hence, am not able to access the title tag text node and hence am not able to change the contents! Any suggesstions???
