How to use zjrJS.Doc.cT() ("create text")
Used zjrJS Version:
Stable Minified version 20141202t2322 of zjrJS.
There is no newer Beta version available.
Declaration
Goal
A cross-browser method to create new texts, to add to your elements. cT() does not use either innerHTML or textContent. It uses document.createTextNode() instead.
Typical usage
After retrieving or creating an element, use aC(cT(text),element) to add the text to the element. You could set the properties innerHTML or textContent instead, if appropriate. Use cT() if you need the returned TextNode for further manipulation by code.
Member Type
Function.
Value Type
Object (the created TextNode with the desired text), or null.
Parameters
String text: any Javascript-encoded text you like.
Dependencies
None.
Example
zjrJS.Doc.cT(String text)
Goal
A cross-browser method to create new texts, to add to your elements. cT() does not use either innerHTML or textContent. It uses document.createTextNode() instead.
Typical usage
After retrieving or creating an element, use aC(cT(text),element) to add the text to the element. You could set the properties innerHTML or textContent instead, if appropriate. Use cT() if you need the returned TextNode for further manipulation by code.
Member Type
Function.
Value Type
Object (the created TextNode with the desired text), or null.
Parameters
String text: any Javascript-encoded text you like.
Dependencies
None.
Example
<script type="text/javascript" src="zjrJS.version.js" id="zjrJS"></script>
<script type="text/javascript">/* <![CDATA[ */
zjrJS.Doc.aE(window, "load", function(){
//reference the Doc object
var D=zjrJS.Doc;
//create an HtmlAnchorElement (hyperlink)
var A=D.cE("a");
if(A){
//add text to the paragraph
D.aC(D.cT("Follow me"), A);
A.href="https://www.omegajunior.net/";
A.title="Visit the OmegaJunior Consultancy!";
A.style.textDecoration="underline";
//add the paragraph to the body
D.aC(A);
}
//clean up memory
D=A=null;
});
/* ]]> */</script>