[][src]Static p5_sys::global::selectAll

pub static selectAll: SelectAllInternalType

Searches the page for elements that match the given CSS selector string (can be an ID a class, tag name or a combination) and returns them as p5.Elements in an array. The DOM node itself can be accessed with .elt. Returns an empty array if none found. You can also specify a container to search within.

Examples

function setup() {
  createButton('btn');
  createButton('2nd btn');
  createButton('3rd btn');
  let buttons = selectAll('button');

  for (let i = 0; i < buttons.length; i++) {
    buttons[i].size(100, 100);
  }
}
// these are all valid calls to selectAll()
let a = selectAll('.beep');
a = selectAll('div');
a = selectAll('button', '#container');

let b = createDiv();
b.id('container');
let c = select('#container');
a = selectAll('p', c);
a = selectAll('#container p');

let d = document.getElementById('container');
a = selectAll('.boop', d);
a = selectAll('#container .boop');
console.log(a);

Parameters

selectors CSS selector string of elements to search for

container? CSS selector string, p5.Element , or HTML element to search within