user3191724
user3191724

Reputation: 159

How to extract the <title> value

JS is not my main skill, hope someone can help. I am trying to make a GTM variable to extract . Problem is that I cant use class="rg-trailer-icon" as a class name because it changes based on the truck type that is viewed (trailer, truck, etc)

enter image description here

Thank you!

Upvotes: 0

Views: 227

Answers (2)

dup
dup

Reputation: 26

in javascript, using document.title should be enough

Upvotes: 0

Maik Lowrey
Maik Lowrey

Reputation: 17566

You can extract the title. You just have to scramble through.

t = document.querySelector('#scheduleContainer svg title').innerHTML
console.log(t)
<div id="scheduleContainer">
  <div>
    <div>
      <svg>
        <title>Hello</title>
        <path>
          </svg>
      </div>
    </div>
</div>

Upvotes: 1

Related Questions