It's not tag name. The argument of
document.getElementbyId
is the value of the element's attribute
id
; the value should be unique on page:
document.getElementById() — Web APIs | MDN[
^].
Тhis is how you can retrieve the present HTML (textual) representation of some HTML element:
Element.innerHTML — Web APIs | MDN[
^].
The rest of the problem is unclear. What expect element? Why would you need the source of a Web page and what do you want to do with it?
Perhaps that you should understand that if you use JavaScript to modify the content of the page, you modify the actual HTML DOM and hence the rendered presentation of the page. You don't modify the source HTML code of the page. When the page is rendered for the first time, this original text is forgotten and cannot be used.
—SA