Phaser API Documentation


Member of: Phaser.DOM

<static> AddToDOM(element, [parent])


Adds the given element to the DOM. If a parent is provided the element is added as a child of the parent, providing it was able to access it. If no parent was given it falls back to using document.body.


name type arguments description
element HTMLElement

The element to be added to the DOM. Usually a Canvas object.

parent string | HTMLElement <optional>

The parent in which to add the element. Can be a string which is passed to getElementById or an actual DOM object.


The element that was added to the DOM.

  • HTMLElement
Since: 3.0.0
Source: src/dom/AddToDOM.js (Line 7)