How to access html element text in chrome devtools console

Viewed 19317

I have a page with a whole bunch of blackquote tags. In dev console I am typing document.getElementsByTagName("blockquote") that giving me an array.

But if I do document.getElementsByTagName("blockquote").innerText document.getElementsByTagName("blockquote").innerHTML document.getElementsByTagName("blockquote").textContent document.getElementsByTagName("blockquote").outerText document.getElementsByTagName("blockquote").outerHTML

All return undefined

However if I inspect elements of the array document.getElementsByTagName("blockquote") I can see all above properties in place.

How to access at least one of them (innerText, outerHTLM, innerText, outerHTML, textContent) ?

3 Answers

You can also try the following commands:

var elements = document.getElementsByTagName("blockquote");.This will return the list of elements.To access the text of your required element at i index elements[i].value.

Related