Greasy Fork镜像 is available in English.

Tartışmalar » Geliştirme

document.querySelectorAll Crashes the script

§
Gönderildi: 06.08.2022
Düzenlendi: 06.08.2022

Hi, I'm trying to select all the element in a page that have the ".playableTile__heading" tag, but if i use just the querySelector it only selects the first element, and if i try using querySelectorAll the script doesn't load.

  let links = document.querySelectorAll('.playableTile__heading');
  //Using All makes the scipt not work

   links.style.background = 'red';
   //Testing to see if does any change to the page

Is there any way i could make this work? My final goal is to save an array with innerHtml of these elements.

§
Gönderildi: 06.08.2022

document.querySelectorAll('.playableTile__heading').forEach(el => el.style.background = 'red');

§
Gönderildi: 06.08.2022
Düzenlendi: 06.08.2022

This is better though https://pastebin.com/raw/0w0LXFhh

Cevap paylaş

Yanıt göndermek için oturum açın.

长期地址
遇到问题?请前往 GitHub 提 Issues,或加Q群1031348184

赞助商

Fishcpy

广告

Rainyun

注册一下就行

Rainyun

一年攒够 12 元