dollarel is a library based on jQuery that allows for DOM manipulation and interaction.
Users are able to select elements on the page by their tags or class/ids and edit the HTML directly through the API.
Mounting to the window allows for testing in Chrome's developer tools.
window.$l = (selector) => {
if (typeof selector === 'function') {
return documentReadyCallback(selector);
} else if (typeof selector === 'string') {
return cssHtmlCallback(selector);
} else if (selector instanceof HTMLElement) {
return cssHtmlCallback(selector);
}
}
Depending on the type of selector provided by the user, a different callback is utilized to grab the proper element(s). These are returned as an instance of a DOMNodeCollection which can be manipulated using the following methods:
If this method receives an argument, it will become the innerHTML of each of the elements in the collection.
If it does not receive an argument, it returns the innerHTML of the first element in the array.
Clears out the content(innerHTML) of all elements in the collection.
Appends the outerHTML of each element in the argument to the innerHTML of each element in the collection.
Removes all HTML of all the elements in the collection from the DOM and removes all elements from the collection itself.
Returns the attribute as specified in the argument.
Returns a collection of the elements, which match the provided selectors, and are descendants of the element on which the method was called.
Adds a class name to the selected element.
Removes a class name from the selected element.
Returns a collection of all the children of all elements in the target collection.
Returns a collection of all the parents of each element in the target collection.
Takes in two arguments, an event and a callback.
Adds an event listener for each element in the collection.
Takes off the event listener, event, and callback from each element in the collection.