p5.js | selectAll() Function
The selectAll() function is used to search for elements with the given id, class or tag name and return it as a p5.Element array. It has a syntax similar to the CSS selector. An optional parameter is available that can be used to search within a given element. This method returns all the elements that exist on the page and matches the selector.
Parameters: This function accept two parameters as mentioned above and described below:
- name: This is a string which denotes the id, class or tag name of the element that has to be searched.
- container: This is an optional parameter which denotes an element to search within.
Returns: It returns a p5.Element array that contains all the matched elements.
Below example illustrates the selectAll() function in p5.js:
Online editor: https://editor.p5js.org/