I will explain my question with an example, I work on a script, and I do not correctly record the span in the console.

here is a piece of code script

I take a specific element in the row and in the column and write it into a variable, after such operations I output everything to the console to check the log for everything and see what I see in the screenshot, but Object ObjectList, I expected a different result, I was expecting 2 The option to write to a variable is either span.GoodNumber or span.BadNumber.

But I do not know why it is the Object NodeList that is being written. If anyone can explain how to write it all down correctly, I will be grateful.

UPD:

I expect to get from this selector value = span.BadNumber or span.GoodNumber for the code block where I will equal the values
This is my code:

let value1 = document.querySelectorAll('table.BetsTable > tbody > tr.MyBet:nth-child(1) > td:nth-child(5) > span'); let value2 = document.querySelectorAll('table.BetsTable > tbody > tr.MyBet:nth-child(2) > td:nth-child(5) > span'); let value3 = document.querySelectorAll('table.BetsTable > tbody > tr.MyBet:nth-child(3) > td:nth-child(5) > span'); 

Then:

 if (value1 && value2 && value3 === BadNumber) 

BadNumber variable to write to (document.querySelectorAll('table.BetsTable > tbody > tr.MyBet > td > span.BadNumber'))

I downloaded another site, the logic is this, you need to check for BadNumber from the first three lines of profit, if all 3 lines are equal to BadNumber, then the script is launched.

site

  • Comments are not intended for extended discussion; conversation moved to chat . - Yuriy SPb 8:49 pm

2 answers 2

 let value1 = document.querySelector( 'table.BetsTable > tbody > tr.MyBet:nth-child(1) > td:nth-child(5) > span'); ... if (value1.classList.contains("BadNumber") && value2.classList.contains("BadNumber") && value3.classList.contains("BadNumber")) { ... } 
  • thanks, I will try, everyone who helped, I will thank the crypt mine with a full script) - DaymaNkinG
  • Helped Stranger in the Q, Grundy, Igor - as the script will be finished, I will send you my script in lichka ) - DaymaNkinG
  • please write where you can write to you in lichku) - DaymaNkinG

document.querySelectorAll returns a collection of elements, but you wanted to get specific elements, for this you had to either take them by index, for example [0] , or use document.querySelector , which just returns the desired element.

However, you can do with a single call document.querySelectorAll .

You can immediately select the desired elements with the desired class, and check their number:

 if (document.querySelectorAll( 'table.BetsTable > tbody > tr.MyBet:nth-child(1) > td:nth-child(5) > span.Bad, ' + 'table.BetsTable > tbody > tr.MyBet:nth-child(2) > td:nth-child(5) > span.Bad, ' + 'table.BetsTable > tbody > tr.MyBet:nth-child(3) > td:nth-child(5) > span.Bad').length == 3) { // все три с классом Bad }