_setParentObject
sets the parent Object for the _render
function.
Requires
import {_setParentObject,_render,_newTag} from "./tt/ttHTML.js";
Definition
_setParentObject (parent);
Description
_setParentObject
sets the parent-Object to prepare the _render
function. _render
will add childs to the given parent-object.
Parameters
parent
: could be either the strings "HEAD" or "BODY", so that _render
will add childs to the <head>
or the <body>
section of the current document. The parent
accepts also any kind of DOM-Object, so _render
will add its childs to that DOM-Object.
Return Value
-
Remarks
-
Example 1: add Element to the HEAD-Section
main.js:
import {_setParentObject,_render,_newTag} from "./tt/ttHTML.js";
_setParentObject("HEAD");
_render(<script>alert ("tiktag is in your Head!");</script>);
Output:

Example 2: create and extend list
main.js:
import {_setParentObject,_render,_newTag} from "./tt/ttHTML.js";
/* without prior initialization _render adds elements to the body-section _render will create a list including the first item in it.*/
_render(<ul id="myList"><li>Item No: 1</li></ul>);
/* switch parent Object to the newly created list */
_setParentObject(document.getElementById("myList"));
/* This loop will add another 19 list-items to the existing list */
for (let i=0;i<19;i++)
_render(<li>Item No: {i+2}</li>);
Output:
