@bqardi/ultimate-element-creator
v1.0.1
Published
Create advanced elements with tag name, class name, id and attributes.
Downloads
3
Maintainers
Readme
Ultimate element creator
Create elements by tag-name and optionally attributes...
Important!
If attributes are needed, you MUST pass in an array with exactly two items in it, where the first is the attribute name and the second is the attributes value: ["class", "myClass"]
.
This way, you can create as many attributes as you like.
To import into your project:
Place this line of code at the top of your JavaScript file:
import createElement from "https://unpkg.com/@bqardi/[email protected]/index.js";
Then you can call the function createElement()
when you need it:
Example usage:
// creating a div element without attributes
let myElement = createElement("div");
With attributes:
// creating an image element and several of its attributes (id, src and alt)
let myElement = createElement("img", ["id", "myID"], ["src", "./path/to/file"], ["alt", "This is my image"]);