Takes a string of html and then creates a DOM Element from it. The HTML is set as the innerHTML
property of the created element.
let form = `
<input type="text" name="nameField" placeholder="Enter your name" style="font-size: 32px">
<input type="button" name="playButton" value="Let's Play" style="font-size: 32px">
`;
You can create a DOM Element from it using the string:
this.add.dom().createFromHTML(form);
The optional elementType
argument controls the type of container that is created, into which the html is inserted.
The default is a plain div
object, but any valid tagName can be given.
If this Game Object already has an Element, it is removed from the DOM entirely first. Any event listeners you may have previously created will need to be re-created after this call.
name | type | arguments | Default | description |
---|---|---|---|---|
html | string |
A string of html to be set as the |
||
tagName | string | <optional> | 'div' |
The tag name of the element into which all of the html will be inserted. Defaults to a plain div tag. |
This DOM Element instance.