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
- CSS | :last-child Selector
- How to use a not:first-child selector in CSS?
- CSS | :first-child Selector
- CSS | :nth-last-child() Selector
- CSS | :nth-child() Selector
- jQuery | :only-child Selector
- CSS Child vs Descendant selectors
- jQuery | :nth-last-child() Selector
- jQuery | :nth-child() Selector
- jQuery | :last-child Selector
- jQuery | :first-child Selector
- How to get specific number of child elements using CSS?
- jQuery | parent > child Selector
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.