With this Action, you can create DOM elements to be insert into your HTML document. For example, you could create an EMBED
element to insert a movie into your document.
To start, choose a 'Create Element' action from the 'Logic' popup menu. This will put an action into your workflow. When this action runs, it creates a new DOM element (such as a DIV) and inserts it into your page. To set up what sort of element is created, and what properties it has you need to edit a few things in the action:
Variable Name: This can be a global variable, a local variable, or a property in the 'event' object. i.e. 'var myelement
' for local, event.myelement
for an event property. If you are planning to use the element in other actions/code, then you should use a global variable or an event property. If you want access to it from anywhere in your code, a global variable is best.
Tag Name: This is the type of element you want to make, such as 'DIV
', 'EMBED
' etc.
Affect Element: This where the new element will be appended. If you wish to just put the element anywhere on the page, use 'document.body
', but if you want it to be within an existing DOM element, you choose it from the list.
Attributes: After the element is created, the Create Element action can apply attributes to the element. For example, if the element is an IMG
you may wish to set the src
attribute.
Like most Lucid actions, you may call another action once this one has completed. If you choose to put the new element into an event property such as event.mynewelement
then the next action, and subsequent actions will be able to access the new element from this property.