VeamsQuery
Represents a very simple DOM API for Veams-JS (incl. ajax support)
Getting started
Installation
npm
npm install veams-query --save
Bower
bower install veams-query --save
Usage
Documentation of all functions (Selector, support and DOM)
Selector function
VeamsQuery( selector:string|object, context:object )
/*** VeamsQuery selector function** @param {String | Object} selector - selector (string, VeamsQuery object, element)* @param*/
Support functions
VeamsQuery.parseHTML( htmlString:string )
/*** Return DOM element created from given HTML string** @param* @return*/
VeamsQuery.ajax( opts:object )
/*** Send XMLHttpRequest** @param* @param* @param* @param* @param*/
DOM functions
.find( selector:string|object )
/*** Get the descendants of each element in the current set of matched elements, filtered by a selector,* VeamsQuery object, or element** @param* @return*/
.closest( selector:string )
/*** For each element in the set, get the first element that matches the selector by testing* the element itself and traversing up through its ancestors in the DOM tree** @param* @return*/
.eq( index:number )
/*** Reduce the set of matched elements to the one at the specified index** @param* @return*/
.hasClass( className:string )
/*** Check if element has given class** @param* @return*/
.is( selector:string )
/*** Check the current matched set of elements against a selector, element, or VeamsQuery object* and return true if at least one of these elements matches the given arguments** @param* @return*/
.addClass( classNames:string )
/*** Add the specified class(es) to each element in the set of matched elements** @param* @return*/
.removeClass( [classNames:string] )
/*** Remove a single class, multiple classes, or all classes from each element in the set of matched elements.** @param* @return*/
.attr( attrName:string )
/*** Get the value of an attribute for the first element in the set of matched elements** @param* @return*/
.attr( attrName:string, attrVal:string|number|boolean )
/*** Set value of an attribute for the set of matched elements** @param* @param* @return*/
.removeAttr( attrName:string )
/*** Remove an attribute from each element in the set of matched elements** @param* @return*/
.css( cssProp:string )
/*** Get the computed style properties for the first element in the set of matched elements** @param* @return*/
.css( cssProp:string|object, cssVal:string)
/*** Set the content of each element in the set of matched elements to the specified text** @param* @param* @return*/
.outerHeight( includeMargin:boolean)
/*** Get the current computed height for the first element in the set of matched elements,* including padding, border and optionally margin** @param* @return*/
.outerWidth( includeMargin:boolean)
/*** Get the current computed width for the first element in the set of matched elements,* including padding,border and optionally margin** @param* @return*/
.offset()
/*** Get the current coordinates of the first element in the set of matched elements,* relative to the document** @return*/
.html()
/*** Get the HTML contents of the first element in the set of matched elements** @return*/
.html( htmlStr:string )
/*** Set the HTML contents of each element in the set of matched elements** @param* @return*/
.text()
/*** Get the combined text contents of each element in the set of matched elements** @return*/
.text( text:string )
/*** Set the content of each element in the set of matched elements to the specified text** @param* @return*/
.prepend( element:string|object )
/*** Insert content, specified by the parameter, to the beginning of each element in the set* of matched elements** @param* @return*/
.append( element:string|object )
/*** Insert content, specified by the parameter, to the end of each element in the set of matched elements** @param* @return*/
.before( element:string|object )
/*** Insert content, specified by the parameter, before each element in the set of matched elements** @param* @return*/
.after( element:string|object )
/*** Insert content, specified by the parameter, after each element in the set of matched elements** @param* @return*/
.remove()
/*** Remove the set of matched elements from the DOM** @return*/
.empty()
/*** Remove all child nodes of the set of matched elements from the DOM** @return*/
.clone( [withChildren:boolean] )
/*** Create a deep copy of the first element in the set of matched elements (without data and events)** @param* @return*/
.index()
/*** Return an integer indicating the position of the first element in the set of matched elements relative* to its sibling elements** @return*/
.prop( propName:string )
/*** Get the value of a property for the first element in the set of matched elements** @param* @return*/
.prop( propName:string, propVal:string|number|boolean|object )
/*** Set value of a property for the set of matched elements** @param* @param* @return*/
.val()
/*** Get the current value of the first element in the set of matched elements.** @return*/
.val( val:string )
/*** Set the value of each element in the set of matched elements** @param* @return*/
.serialize()
/*** Encode a set of form elements as a string for submission.** @return*/
.on( eventNames:string[, selector:string] ,handler:function[, useCapture:boolean])
/*** Attach an event handler function for one or more events to the selected elements** @param* @param* @param* @param* @return*/
.off( eventNames:string[, selector:string])
/*** Detach all event handlers for one or more event types from the selected elements** @param* @param* @param* @return*/
.trigger( eventNames:string[, customData:object])
/*** Execute all handlers and behaviors attached to the matched elements for the given event type** @param* @param* @return*/