Class: _$

_$(parameter, contextopt)

LightQuery holder class

Constructor

new _$(parameter, contextopt)

Parameters:
Name Type Attributes Description
parameter Element | NodeList | Array | String | Document | Window | function | _$ The parameter to initialize the _$ object with
context Element <optional>
Potential query context
Source:

Extends

  • Array

Methods

(static) ajax(parameter, settingsopt) → {XMLHttpRequest}

Send an AJAX request
Parameters:
Name Type Attributes Description
parameter String | Object URL of the request or settings object
settings Object <optional>
Settings object
Properties
Name Type Attributes Default Description
data Object | FormData <optional>
Request data
dataType String <optional>
json Response data type
error errorCallback <optional>
Callback for the error event
headers Object.<String, String> <optional>
Request headers
method String <optional>
GET Request method
success successCallback <optional>
Callback for the success event
url String <optional>
Request URL
Source:
Returns:
The XHR request
Type
XMLHttpRequest

(static) get(url, dataopt, successopt, dataTypeopt) → {XMLHttpRequest}

Shorthand for sending a GET AJAX request
Parameters:
Name Type Attributes Description
url String URL of the request or settings object
data Object <optional>
Request data
success successCallback <optional>
Callback for the success event
dataType String <optional>
Response data type
Source:
Returns:
The XHR request
Type
XMLHttpRequest

(static) insert(toInsert, position, relativeElements) → {_$}

Shorthand to insert element(s) relative to other(s)
Parameters:
Name Type Description
toInsert Element | NodeList | Array | String | _$ The elements to insert
position String The position of the new elements
relativeElements Element | NodeList | Array | String | _$ The elements to position from
Source:
Returns:
A new LightQuery object containing the inserted nodes
Type
_$

add(parameter, contextopt) → {_$}

Add elements to the current _$ elements
Parameters:
Name Type Attributes Description
parameter Element | NodeList | Array | String | _$ Element(s) to add
context Element <optional>
Context of the potential query
Source:
Returns:
The current object
Type
_$

addClass(parameter) → {_$}

Add class(es) to each element
Parameters:
Name Type Description
parameter String Space separated classes to add
Source:
Returns:
The current object
Type
_$

after(…elements) → {_$}

Insert content after each element
Parameters:
Name Type Attributes Description
elements Element | NodeList | Array | String | _$ | Array.<Element> | Array.<NodeList> | Array.<Array> | Array.<String> | Array.<_$> <repeatable>
Elements to be inserted
Source:
Returns:
The current object
Type
_$

append(…elements) → {_$}

Append content to the end of each element
Parameters:
Name Type Attributes Description
elements Array.<Element> | Array.<NodeList> | Array.<Array> | Array.<String> | Array.<_$> <repeatable>
Elements to be appended
Source:
Returns:
The current object
Type
_$

appendTo(targets) → {_$}

Append each element to the end of the targets
Parameters:
Name Type Description
targets Element | NodeList | Array | String | _$ Elements to be appended to
Source:
Returns:
The current object
Type
_$

attr(name, valueopt) → {_$|String}

Set/Get an attribute for each element
Parameters:
Name Type Attributes Description
name String The attribute name
value String | Number | null <optional>
The attribute value
Source:
Returns:
The current object or the value of the attribute
Type
_$ | String

before(…elements) → {_$}

Insert content before each element
Parameters:
Name Type Attributes Description
elements Array.<Element> | Array.<NodeList> | Array.<Array> | Array.<String> | Array.<_$> <repeatable>
Elements to be inserted
Source:
Returns:
The current object
Type
_$

blur() → {_$}

Force the focus out of each element
Source:
Returns:
The current object
Type
_$

children(selectoropt) → {_$}

Get the children of each element
Parameters:
Name Type Attributes Description
selector String <optional>
An optional filter
Source:
Returns:
The current object's children
Type
_$

clone(deepopt) → {_$}

Clone each element
Parameters:
Name Type Attributes Default Description
deep Boolean <optional>
true Deep clone the elements ?
Source:
Returns:
A clone of the previous object
Type
_$

closest(selector) → {_$}

Get the closest (self-included) parent matching the selector for each element
Parameters:
Name Type Description
selector String The selector
Source:
Returns:
A new LightQuery object
Type
_$

contents() → {_$}

Get the children of each element (including text nodes)
Source:
Returns:
A LightQuery object containing the child nodes
Type
_$

css(parameter, valueopt) → {_$}

Set/Get a CSS property
Parameters:
Name Type Attributes Description
parameter String | Object The CSS property name or an object containing every CSS properties to be changed
value String <optional>
The CSS property value
Source:
Returns:
The current object
Type
_$

detach() → {_$}

Remove each element from the DOM, to be reused later
Source:
Returns:
The current object
Type
_$

each(callback) → {_$}

Iterate over each element Inside this method, `this` corresponds to the current element
Parameters:
Name Type Description
callback function The callback function
Source:
Returns:
The current object
Type
_$

empty() → {_$}

Remove all child nodes of each element
Source:
Returns:
The current object
Type
_$

eq(index) → {_$}

Get the Nth element (a negative N starts counting from the end)
Parameters:
Name Type Description
index Number The element index
Source:
Returns:
The Nth element's object
Type
_$

filter(parameter) → {_$}

Filter elements from a selector or a function returning a Boolean
Parameters:
Name Type Description
parameter String | function A selector or a filtering function
Source:
Returns:
The filtered object
Type
_$

find(selector) → {_$}

Find descendants of each element corresponding to the selector
Parameters:
Name Type Description
selector String The selector
Source:
Returns:
The corresponding descendants' object
Type
_$

first() → {_$}

Get the first element
Source:
Returns:
The first element's object
Type
_$

get(indexopt) → {Element|Array.<Element>}

Get one or every element
Parameters:
Name Type Attributes Description
index Number <optional>
The element index (null to get every element)
Source:
Returns:
The requested element(s)
Type
Element | Array.<Element>

has(parameter) → {_$}

Reduce the elements based on a descendant selector or descendant element
Parameters:
Name Type Description
parameter String | Element The selector or element to reduce with
Source:
Returns:
The corresponding elements' object
Type
_$

hasClass(className) → {Boolean}

Determine if at least one element contains the given class
Parameters:
Name Type Description
className String The class name
Source:
Returns:
`true` if an element contains the class, `false` otherwise
Type
Boolean

height() → {Number}

Get the computed height of the first element
Source:
Returns:
The computed height of the first element (px)
Type
Number

hide() → {_$}

Hide each element
Source:
Returns:
The current object
Type
_$

html(htmlopt) → {_$}

Get the HTML of the first element or Set each element's HTML
Parameters:
Name Type Attributes Description
html String <optional>
The HTML to set
Source:
Returns:
The current object
Type
_$

index() → {Number}

Get the first element's index in relation to its siblings
Source:
Returns:
The index
Type
Number

insertAfter(target) → {_$}

Insert each element after the target(s)
Parameters:
Name Type Description
target Element | NodeList | Array | String | _$ The target(s)
Source:
Returns:
The current object
Type
_$

insertBefore(target) → {_$}

Insert each element before the target(s)
Parameters:
Name Type Description
target Element | NodeList | Array | String | _$ The target(s)
Source:
Returns:
The current object
Type
_$

is(target) → {Boolean}

Check if at least one of the elements matches the target
Parameters:
Name Type Description
target String | function | Element | _$ The target or Function to match against
Source:
Returns:
`true` if at least one of the elements matches the target, `false` otherwise
Type
Boolean

last() → {_$}

Get the last element
Source:
Returns:
The last element's object
Type
_$

next(selectoropt) → {_$}

Get next immediate sibling. If a selector is provided, doesn't return the sibling if it doesn't match
Parameters:
Name Type Attributes Description
selector String <optional>
The sibling selector
Source:
Returns:
The next immediate sibling
Type
_$

nextAll(selectoropt) → {_$}

Get next siblings. If a selector is provided, doesn't return the siblings if they don't match
Parameters:
Name Type Attributes Description
selector String <optional>
The sibling selector
Source:
Returns:
The next siblings
Type
_$

not(target) → {_$}

Remove elements matching the target from the current object
Parameters:
Name Type Description
target Element | NodeList | Array | String | function | _$ The target
Source:
Returns:
Object containing elements not matching the target
Type
_$

off(events, selectoropt, handleropt) → {_$}

Remove an event handler
Parameters:
Name Type Attributes Description
events String The events to stop listening to
selector String <optional>
The selector matching the one used with _$#on
handler function <optional>
The handler used with _$#on
Source:
Returns:
The current object
Type
_$

offset() → {DOMRect}

Get the coordinates of the first element
Source:
Returns:
Object containing the coordinates of the first element. *Use `.left`, `.top`*
Type
DOMRect

on(events, selectoropt, handler, dataopt) → {_$}

Add an event handler
Parameters:
Name Type Attributes Description
events String The events to start listening to
selector String <optional>
The selector used for event delegation
handler function The handler for the event(s)
data Object <optional>
The data to be passed the the handler
Source:
Returns:
The current object
Type
_$

parent(selectoropt) → {_$}

Get the parent of each element. If a selector is passed, filter those parents
Parameters:
Name Type Attributes Description
selector String <optional>
The parent selector
Source:
Returns:
The parent(s)
Type
_$

parents(selectoropt) → {_$}

Get the ancestors of each element. If a selector is passed, filter those parents
Parameters:
Name Type Attributes Description
selector String <optional>
The parents selector
Source:
Returns:
The parent(s)
Type
_$

prepend(…elements) → {_$}

Prepend content to the end of each element
Parameters:
Name Type Attributes Description
elements Array.<Element> | Array.<NodeList> | Array.<Array> | Array.<String> | Array.<_$> <repeatable>
Elements to be prepended
Source:
Returns:
The current object
Type
_$

prependTo(targets) → {_$}

Prepend each element before the targets
Parameters:
Name Type Description
targets Element | NodeList | Array | String | _$ Elements to be prepended to
Source:
Returns:
The current object
Type
_$

prev(selectoropt) → {_$}

Get previous immediate sibling. If a selector is provided, doesn't return the sibling if it doesn't match
Parameters:
Name Type Attributes Description
selector String <optional>
The sibling selector
Source:
Returns:
The previous immediate sibling
Type
_$

prevAll(selectoropt) → {_$}

Get previous siblings. If a selector is provided, doesn't return the siblings if they don't match
Parameters:
Name Type Attributes Description
selector String <optional>
The sibling selector
Source:
Returns:
The previous siblings
Type
_$

remove() → {_$}

Remove each element from the DOM
Source:
Returns:
The current object
Type
_$

removeAttr(attribute) → {_$}

Remove an attribute from each element
Parameters:
Name Type Description
attribute String Attribute name
Source:
Returns:
The current object
Type
_$

removeClass(classes) → {_$}

Remove class(es) from each element
Parameters:
Name Type Description
classes String Space separated classes to remove
Source:
Returns:
The current object
Type
_$

replaceAll(targets) → {_$}

Replace each target with each element
Parameters:
Name Type Description
targets Element | NodeList | Array | String | _$ The targets
Source:
Returns:
The current object
Type
_$

replaceWith(newContent) → {_$}

Replace each element with the new content
Parameters:
Name Type Description
newContent Element | NodeList | Array | String | _$ The new content
Source:
Returns:
The current object
Type
_$

scrollLeft(valueopt) → {Number|_$}

Get the horizontal scroll value of the first element or set the horizontal scroll value for each element
Parameters:
Name Type Attributes Description
value Number <optional>
The new horizontal scroll value
Source:
Returns:
The horizontal scroll value of the first element or the current object
Type
Number | _$

scrollTop(valueopt) → {Number|_$}

Get the vertical scroll value of the first element or set the vertical scroll value for each element
Parameters:
Name Type Attributes Description
value Number <optional>
The new vertical scroll value
Source:
Returns:
The vertical scroll value of the first element or the current object
Type
Number | _$

serialize() → {String}

Encode each form element as a string
Source:
Returns:
The serialized value of each element
Type
String

serializeArray() → {Array.<Object>}

Encode each form element as an array of names and values
Source:
Returns:
An array of names and values
Type
Array.<Object>

show() → {_$}

Show each element
Source:
Returns:
The current object
Type
_$

siblings(selectoropt) → {_$}

Get all siblings. If a selector is provided, doesn't return the siblings if they don't match
Parameters:
Name Type Attributes Description
selector String <optional>
The sibling selector
Source:
Returns:
The siblings
Type
_$

text(valueopt) → {String|_$}

Get/Set the text of each element
Parameters:
Name Type Attributes Description
value String | function <optional>
Text to set or Function returning the text to set
Source:
Returns:
The text of each element or the current object
Type
String | _$

toggle(forceopt) → {_$}

Toggle each element's display
Parameters:
Name Type Attributes Description
force Boolean <optional>
`true` to show, `false` to hide
Source:
Returns:
The current object
Type
_$

toggleClass(classes) → {_$}

Toggle class(es) for each element
Parameters:
Name Type Description
classes String Space separated classes to toggle
Source:
Returns:
The current object
Type
_$

trigger(eventName) → {_$}

Trigger an event for each element
Parameters:
Name Type Description
eventName String Event name
Source:
Returns:
The current object
Type
_$

unwrap(selectoropt) → {_$}

Remove the direct parents of each element, if they match the selector
Parameters:
Name Type Attributes Description
selector String <optional>
The parent selector
Source:
Returns:
The current object
Type
_$

val(valueopt) → {String|_$}

Get the value of the first element or set the value of each element
Parameters:
Name Type Attributes Description
value Object <optional>
The value to set
Source:
Returns:
The value of the first element or the current object
Type
String | _$

width() → {Number}

Get the computed width of the first element
Source:
Returns:
The computed width of the first element (px)
Type
Number

wrap(wrapper) → {_$}

Wrap each element
Parameters:
Name Type Description
wrapper Element | NodeList | Array | String | _$ The wrapper
Source:
Returns:
The current object
Type
_$

wrapAll(wrapper) → {_$}

Wrap all elements
Parameters:
Name Type Description
wrapper Element | NodeList | Array | String | _$ The wrapper
Source:
Returns:
The current object
Type
_$