Elementool is a versatile JavaScript library designed to simplify the creation, manipulation, and interaction of HTML, SVG, and MathML elements in web applications. This library provides an intuitive API for developers to easily generate and control various types of web elements, offering robust features for dynamic styling, event handling, and element management.
Include the Elementool library in your HTML file:
<script src="path/to/index.js"></script>
Or, use a module bundler like Webpack or Rollup to import Elementool:
import Elementool from 'path/to/index.js';
Create a new instance of Elementool:
var el = new Elementool();
var main = document.querySelector("main");
el.make("h1", "Hello World!").appendTo(main);
el.make(
"h2",
function() {
return "Dynamic: " + new Date().toISOString().split("T").join(" ").split("Z").join("");
},
{
color: function() { return `rgb(${new Date().getSeconds() * 4}, ${new Date().getMinutes() * 4}, ${new Date().getHours() * 4})`; },
fontSize: function() { return `${20 + (new Date().getSeconds() / 3)}px`; }
}
).appendTo(main);
var svgCircle = el.svgHelpers.circle(50, 50, 40, { fill: 'red' }).appendTo(document.body);
Refer to the detailed documentation for a complete list of functions, parameters, and usage examples.
make(selector, content, styles, eventListeners)draw(selector, content, styles, eventListeners)math(selector, content, styles, eventListeners)svgHelpers.circle(cx, cy, r, styles)svgHelpers.ellipse(cx, cy, rx, ry, styles)... (and more)accessibilityHelpers.description(element, description)accessibilityHelpers.button(element, customDescription)... (and more)Contributions to Elementool are welcome!
Elementool is BSD 3-Clause Licensed.