Get canvas element from document by id - Node.js HTML

Node.js examples for HTML:Canvas

Description

Get canvas element from document by id

Demo Code


    getCanvas: function(id) {
        var canvas = document.getElementById(id);
        if(canvas === null || canvas.nodeName.toLowerCase() !== 'canvas') {
            return document.createElement('canvas');
        }/*from   w  w  w  . ja  v  a  2  s  . c om*/
        return canvas;
    }
};

Related Tutorials