1

I want to get the twitter's name in twitter.

Twitter use this code for every user.

<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0">kya</span>

So I did this, but it doesn't work

let pa = document.getElementById("css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0");

for (elt of pa) {
  console.log(elt.textContent)
}

Also there are a lot of tags with those class name, how could I know if it's the name what I'm getting?

  • You're using `getElementById`. Does the element **have** an id?! – Quentin Mar 31 '20 at 14:37
  • The list of classes is not an ID... Also, it's not guaranteed that this collection of classes is *only* to be found when styling a display name. Nor is it guarananteed to stay the same. – VLAZ Mar 31 '20 at 14:38
  • @Quentin I see, what about getElementsByClassName()? it looks like the for doesn't itterate. (Sorry for my english, also I'm pretty new in js, so sorry for that as well) – Georgia Fernández Mar 31 '20 at 14:46

0 Answers0