DOMAssistant Core Module

The DOMAssistant Core module is required and it lays the groundwork for all DOMAssistant functionality. It consists of core functionality and a few important methods to work with.

$(elementId/elementReference/cssSelector)

The $ method is used to get a reference to one or several elements. It supports one or more strings containing the id of the element(s) you want a reference to, or getting an already established element reference. If it gets an element reference, it will return that same reference, but with the difference that it has applied all extra methods to it.

You can also send in a CSS selector where there's support for CSS 1, CS 2 and CSS 3 for getting element references. Read more about the supported CSS selectors.

Parameters

Send in one or several strings with the id of the element(s) you're looking, a single element reference or a CSS selector.

Return value

Returns an element reference when one single argument is sent to the method, being the id or direct reference to an already existing element. Returns an array of element references if multiple ids, element references or a CSS selector is sent in.

Example calls

$("#container input[type=text]");

$("#navigation a");

$("#news-list");

$("container");

$("container", "navigation", "content");

$(document.body);

elmsByClass(className, tag)

For getting elements based on their className. The method has a required parameter which is the desired className, and one optional if you want to limit the search to a certain tag.

Parameters
className
Class name to search for. Required.
tag
Only search elements that have this tag name. Optional.
Return value

All calls return an array of element references.

Example calls

$("container").elmsByClass("mandatory");

$("container").elmsByClass("external-link", "a");

elmsByAttribute(attr, attrVal, tag)

For getting elements based on if they have a certain attribute. You can also specify if that attribute should have a speific value and if you want to limit the search to a certain tag. Only the first parameter specifying the attribute is required.

Parameters
attr
Attribute name to look for. Required.
attrVal
Value that the desired attribute has to have. Optional. Use wildcard character ("*") if you want any attribute value but still want to specify tag.
tag
Only search elements that have this tag name. Optional.
Return value

All calls return an array of element references.

Example calls

$("container").elmsByAttribute("href");

$("container").elmsByAttribute("name", "subscription");

$("container").elmsByAttribute("type", "text", "input");

elmsByTag(tag)

For getting elements based on their tag, i.e. what element it is. The method has one required parameter which is the name of the desired tag.

Return value

All calls return an array of element references.

Parameters
tag
Tag name to search for. Required.
Example calls

$("container").elmsByTag("input");

each(functionRef)

For running a function on each of the items in a returned array element reference collection.

Return value

All calls return either a single element reference or an array of element references.

Parameters
functionRef
Function which will be called for each item in the array of elements it's called on. Can be an anonymous function or a function reference.
Example calls

$("#navigation a").each(function () {
// Do some JavaScript magic
});

Download DOMAssistant

All modules in one file

DOMAssistant 2.5.7, compressed
(22kb, 7kb Gzipped)
Intended for production usage.
DOMAssistant 2.5.7, complete
(43kb)
Intended for learning and development usage.

Individual modules

Get your copy