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 | :nth-last-child() Selector
- CSS | :first-child Selector
- CSS | :only-child Selector
- CSS | :last-child Selector
- How to use a not:first-child selector in CSS?
- CSS | :nth-child() Selector
- CSS | :not(:last-child):after Selector
- jQuery | :last-child Selector
- jQuery | :only-child Selector
- CSS Child vs Descendant selectors
- jQuery | :nth-child() Selector
- jQuery | :first-child Selector
- jQuery | :nth-last-child() Selector
- Last-child and last-of-type selector in SASS
- How to get specific number of child elements using CSS?
- How to count child element using jQuery ?
- How to iterate through child elements of a div using jQuery ?
- How to apply style to parent if it has child with 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 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.