The child() function is used to add the element as a child element to the parent element. This function accepts either a string ID, DOM node, or p5.Element. If this function does not contain any parameters then it returns an array of children DOM nodes.
Note: This function uses the p5.dom library. So add the following line in the head section of the index.html file.
child( child )
Parameters: This function accepts single parameter child which holds the string or p5.Element. The ID, DOM node, or p5.Element is used to add as a current element.
Return Value: It returns an array of child nodes.
Below example illustrates the child() function in p5.js:
- CSS | :only-child Selector
- How to use a not:first-child selector in CSS?
- CSS | :nth-last-child() Selector
- CSS | :nth-child() Selector
- CSS | :first-child Selector
- CSS | :not(:last-child):after Selector
- CSS | :last-child Selector
- jQuery | :only-child Selector
- jQuery | :last-child Selector
- jQuery | :nth-last-child() Selector
- jQuery | :first-child Selector
- CSS Child vs Descendant selectors
- jQuery | :nth-child() Selector
- Last-child and last-of-type selector in SASS
- How to select all children of an element except the last child using CSS?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.