zjrJS Javascript Library

zjrJS.Doc.ct() - zjrJS Javascript Library

This information lives on a webpage hosted at the following web address: 'https://omegajunior.globat.com/code/zjrjs/'.

How to use zjrJS.Doc.cT() ("create text")

Declaration
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>

Download:

Download zjrJS’ latest stable build (20141202t2322) minified (7.1KB).

Download zjrJS’ latest stable build (20141202t2322) (11.9KB).

Clicky Analytics