Skip to content

Instantly share code, notes, and snippets.

@think49
Created December 28, 2010 16:37
Show Gist options
  • Select an option

  • Save think49/757398 to your computer and use it in GitHub Desktop.

Select an option

Save think49/757398 to your computer and use it in GitHub Desktop.
Div.js: new Div で [object HTMLDivElement] を生成するコンストラクタ。new Image の真似。
/**
* Div.js
*
* @version 0.2
* @author think49
*/
/**
* DOM HTMLDivElement constructor.
* @constructor
* @returns "[object HTMLDivElement]"
* @type Object
*/
function Div () {
if (!(this instanceof Div)) {
throw new TypeError('DOM object constructor cannot be called as a function.');
}
return document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment