DOM Append Text and Element Functions

Submitted by:J Kamy81

Date added:30 November, 2017

Category:JavaScript

Javascript append function "DOM Append Text and Element Functions"

Tags: append text , javascript append function , element functions

Code Snippet:

/* Created by: HunBug | http://www.astral-consultancy.co.uk/cgi-bin/hunbug/doco.cgi?11430 */

function appendText(node,txt) {
node.appendChild(document.createTextNode(txt));
}

function appendElement(node,tag,id,htm) {
var ne = document.createElement(tag);
if(id) ne.id = id;
if(htm) ne.innerHTML = htm;
node.appendChild(ne);
}

 
 

Comments