This basic element creator allows you to create elements with a class without the need of external tools.
Import the class into your javascript module, and create elements to your hearts content!
You can declare elements and append them to elements with an ID reference, and continue to use javascripts built in element manipulation functionality
Each element is given a data-identifier , so now we can easily add and remove id's and elements, even after its been placed on the DOM!
new Element(
- String: elementType (default is div),
- String: id (default is null),
- String: class (default is null),
- String: identifier (default is identifier) )
let main = new Element(main).append('idName')
main.setID('mainContainer')
let div = new Element().append(main.getID())
main.element.textContent = 'This is a novel idea'
main.update()
new Element(this.elementType,this.idName,this.className, this.identifier)
String: this.idName
new Element(this.elementType,this.idName,this.className, this.identifier)
String: this.className
5. .setClass(String: className) - sets the classes of the element, best if done before you append to DOM elements
new Element(this.elementType,this.idName,this.className, this.identifier)
6. .removeClass(String: className) - removes the class specified in the parameter, CURRENTLY REMOVES ONE CLASS AT A TIME!
new Element(this.elementType,this.idName,this.className, this.identifier)
7. .update() - update elements on the DOM that has been been set but not appended yet. Recommend calling this at the very end of updating all values
new Element()setID('mainDiv').setClass('row p-4').append('someID').update()
new Element(this.elementType,this.idName,this.className, this.identifier)
WARNING DO NOT TRY TO APPEND AN ELEMENT TO ITSELF! (WIP) !!! UPDATE !!! YOU CAN NOW APPEND AN ELEMENT TO ITSELF
Its still a work in progress, so its a simple tool that allows you to save a bit of time Development will continue to take into account unique attributes of form elements, images etc.