| 1 |
# removeChild |
| 2 |
|
| 3 |
```php |
| 4 |
removeChild ( object $node ) |
| 5 |
``` |
| 6 |
|
| 7 |
| Parameter | Description |
| 8 |
| --------- | ----------- |
| 9 |
| `node` | Node to remove from current element, must be a child of the current element. |
| 10 |
|
| 11 |
Removes the node recursively from the DOM. |
| 12 |
Does nothing if the provided node is not a child of the current node. |
| 13 |
|
| 14 |
**Example** |
| 15 |
|
| 16 |
```php |
| 17 |
$html = str_get_html(<<<EOD |
| 18 |
<html> |
| 19 |
<body> |
| 20 |
<table> |
| 21 |
<tr><th>Title</th></tr> |
| 22 |
<tr><td>Row 1</td></tr> |
| 23 |
</table> |
| 24 |
</body> |
| 25 |
</html> |
| 26 |
EOD |
| 27 |
); |
| 28 |
|
| 29 |
$body = $html->find('body', 0); |
| 30 |
$body->removeChild($body->find('table', 0)); |
| 31 |
|
| 32 |
echo $html; |
| 33 |
|
| 34 |
/** |
| 35 |
* Returns |
| 36 |
* |
| 37 |
* <html> <body> </body> </html> |
| 38 |
*/ |
| 39 |
``` |
| 40 |
|
| 41 |
**Remarks** |
| 42 |
|
| 43 |
* Whitespace immediately **before** the removed node will remain in the DOM. |