Skip to content
This repository has been archived by the owner on Jun 7, 2018. It is now read-only.

[Deprecated] Create your own elements through client-side JavaScript.

Notifications You must be signed in to change notification settings

thatlittlegit/betterelement

Repository files navigation

DEPRECATED

Use this instead of the "Hello World" below:

[...document.getElementsByTagName('hello')].map(element => {
	element.innerHTML = 'hello';
	if (Math.random() < 0.51) {
		element.innerHTML += ' world!';
	} else {
		element.innerHTML += ' death!';
	}
});

No library needed!

(For ES3, use a for loop instead.)

Create your own elements through client-side JavaScript.

Installation

npm i betterelement
# or, with Yarn,
yarn add betterelement

Usage

// First, create a new Element.
var element = new Element('hello');
// Then, let's add a toExecuteOnRead.
element.toExecuteOnRead = function (index, element) {
	element.innerHTML = 'hello';
	if (Math.random() < 0.51) {
		element.innerHTML += ' world!';
	} else {
		element.innerHTML += ' death!';
	}
}
// Now, let's build.
element.readElements();
...
<body>
	<h1><hello></hello></h1>
	<p>
		...
	</p>
	...
</body>
...

Results in:

...
<body>
	<h1><hello>Hello, death!</hello></h1>
	<p>
		...
	</p>
	...
</body>
...

For more examples, see doClock and doRandom in betterelement.js. Here it is in action!

About

[Deprecated] Create your own elements through client-side JavaScript.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published