DOMpler is a program designed to interact with the JavaScript DOM, modeled after JQuery.
DOMpler has the ability to:
- Select single or multiple elements
- Add to or clear the inner HTML of elements
- Append elements to existing ones
- Add or Remove classes
- Add or Remove event listeners
- Return the parent or children of selected elements
- Complete ajax requests and handle promises.
DOMpler uses $l as a global variable to call the methods in the library. It can be used to select elements with CSS selectors, create HTML elements which are then wrapped in a DOMNodeCOllection object, or to queue functions to run once the COM has loaded.
- html: Returns the innerHTML for the first element in the DOMNodeCollection if no argument is given. If a string argument is given, changes the innerHTML of each DOMNodeCollection element to the string argument.
- empty: empties inner HTML of each DOMNodeCollection element
- append: Takes a single HTMLElement, DOMNodeCollection, or string argument and appends it to each DOMNodeCollection element.
- remove: takes a selector argument to specifically remove certain elements from a DOMNodeCollection or will remove all selected elements if no argument is given
- attr: takes an attribute argument and returns the value of that attribute for the first element in the DOMNodeCollection
- addClass: takes a class argument to give to each element of the DOMNodeCollection
- removeClass: takes a class argument to remove from each element of the DOMNodeCollection
$l.ajax: Sends an HTTP request and returns a promise object. Takes a hash object as an argument. The hash can have the following attributes:
- method: HTTP Request type. Default is 'GET'
- url: url for request
- data: a hash object with any values being sent with the request
- success: callback for completed request
- error: callback for failed request
- contentType: content type of request