[Vuejs]-Can not read DOM value, getting Vue.js template (in Chromium, both fom DevTools and extension)

2👍

Especially I need the href attribute of a link (tag <a>)

You’re looking for Element.getAttribute():

console.log(
  ` a.getAttribute('href') => '${document
    .getElementsByClassName("foo")[0]
    .getAttribute("href")}'\n`,
  `span.getAttribute('class') => '${document
    .getElementsByTagName("span")[0]
    .getAttribute("class")}'`
);
<a href="#" class="foo">foo</a>
<span class="page-title-text">bar</span>
👤tao

-1👍

Well, the site has tricked me.

> document.getElementsByClassName("page-title-text")[1]

<span class="page-title-text">The Real Title</span>

There is a hidden first element somewhere, which contains the template, that scared me, and also the empty value caused error, so my script has stopped.

👤ern0

Leave a comment