mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-23 04:29:21 +00:00
32 lines
706 B
JavaScript
32 lines
706 B
JavaScript
/**
|
|
* Utilities functions
|
|
*
|
|
* @author Pierre HUBERT
|
|
*/
|
|
|
|
/**
|
|
* Create a new HTML node
|
|
*
|
|
* @param {String} nodeType The type of the HTML node
|
|
* @param {HTMLElement} appendTo Optionnal, defines node on which the new node will be applied
|
|
* @return {HTMLElement} The newly created element
|
|
*/
|
|
function createElem(nodeType, appendTo){
|
|
var newElem = document.createElement(nodeType);
|
|
|
|
if(appendTo)
|
|
appendTo.appendChild(newElem);
|
|
|
|
//Return result
|
|
return newElem;
|
|
}
|
|
|
|
/**
|
|
* Get an HTML element specified by an ID
|
|
*
|
|
* @param {String} nodeName The ID of the element
|
|
* @return {HTMLElement} The elemnt / False for a failure
|
|
*/
|
|
function byId(nodeName){
|
|
return document.getElementById(nodeName);
|
|
} |