Search code examples
javascriptvariablesgoogle-tag-manager

How to pull <stronG> value using JS


Hope someone can help me here. Trying to pull text only from screenshot below. When I use :

document.getElementsByClassName("heading-2 color-blue")[0].textContent

I get: 'SEALYON Yacht for Sale' (I need only "SEALYON")

Thank you !

enter image description here


Solution

  • This did the job :

    document.getElementsByClassName("heading-2 color-blue")[0].childNodes[0].innerText