2

I have a html page and i have it something like

<title>this is very cool!</title>

i would like to write a javascript function to retrieve the text in between the <Title> tags. I'm familiar with getElementById and getElementsByName, is there something I've missed?

thanks!

1

2 Answers 2

6

You can access it via global document property: document.title

Sign up to request clarification or add additional context in comments.

Comments

1

you can use getElementsByTagName() function to get element text property, try this

document.getElementsByTagName("title")[0].text

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.