Jamón is a lightweight ES6 DOM library.
Use $(selector)
or Jamon.get(selector)
to select a single element:
$("div");
$(".menu");
$("#Header");
Use $$(selector)
or Jamon.getAll(selector)
to select multiple elements:
$$("a > span");
$$(".menu");
$$("#section-1, #section2");
Jamón only registers the globals
$()
and$$()
if they are unused.
Jamón extends the built-in Array so instances behave just like regular arrays.
You can use all array prototype methods
like forEach
, map
, push
, join
, etc, or iterate with for...of
loops.
Provides an Iterable that yields each element wrapped in a Jamón instance
Adds a class name or a list of space-separated class names to the element(s).
Removes a class name or a list of space-separated class names from the element(s).
Toggles a class name or each class name of a space-separated list on the element(s).
Shows the element(s) by adding the hidden
class name.
Hides the element(s) by removing the hidden
class name.
Toggles the element(s) by toggling the hidden
class name.
For show(), hide() and toggle() to work you need to include the following line in your CSS:
.hidden { display: none !important; }
You can customize this class name by changing the value of
Jamon.hiddenClassName
.
Gets the value of the first element or sets the value of each element.
Gets the html content of the first element or sets the html content of each element.
Gets the text content of the first element or sets the text content of each element.
Gets the value of a property of the first element or sets the value of a property of each element.
Gets the value of an attribute of the first element or sets the value of an attribute of each element.
Gets the value of the data attribute for the first element or sets the data attribute value for each element.
Gets the computed value of the CSS property for the first element or sets the value of the CSS property for each element.
Gets the width of the first element.
Gets the height of the first element.
Gets the offset position of the first element relative to the offset parent.
Gets the absolute position of the first element or sets the position of each element relative to the page.
Finds the first descendant that matches the selector in any of the elements.
Finds all descendants that match the selector in each element.
Gets the parent element of each element.
Gets the closest parent matching the selector of each element.
Gets the children elements of each element.
These methods only work with one subject and one target i.e. the first element in the collection.
Prepends another element or string to the element.
Prepends the first element to another element.
Appends another element or string to the element.
Appends the element to another element.
Inserts another element or string before the element.
Inserts the element before another element.
Inserts another element or string after the element.
Inserts the element after another element.
Replaces the element with another element.
Replaces another element with the element.
Clones each element in the collection.
Removes each element from the DOM.
Adds the listener for each of the events to each element. Provide an optional selector string for event delegation.
Removes the standard or delegated event listeners from the elements.
Triggers an event on each element. The additional event data can be accessed in the event.detail property. Supported native events: mouse, focus and keyboard events.
Creates a new Jamón collection with only one element.
Creates a new Jamón collection with multiple elements.
Creates a new HTML element.
Jamon.hiddenClassName
Overrides the default class name hidden
used for hiding elements.