dimanche 5 décembre 2021

how do i check the textcontent inside a button. the if statement isnt recognising the text

Linkedin search result so on the search page i want to only select the buttons with connect on them. the if statement doesnt seem to check if connect is the text content.

var buttons = document.getElementsByClassName('artdeco-button artdeco-button--2 artdeco-button--secondary ember-view')
for (var i = 0; i < buttons.length; i++) {
  console.log(buttons[i].textContent)
  if (buttons[i].textContent == 'Connect') {
    console.log(i)
  }

}
<button aria-label="Invite x to connect" id="ember82" class="artdeco-button artdeco-button--2 artdeco-button--secondary ember-view"><!---->
    <span class="artdeco-button__text">
        Connect
    </span></button>

result Shouldnt the connect have an corresponding i?

Aucun commentaire:

Enregistrer un commentaire