new Query(selector) → {Query}
Create a new Query.
Parameters:
Name | Type | Description |
---|---|---|
selector |
string | Node | NodeList | A valid CSS selector string or Node or NodeList. |
Returns:
- Type
- Query
Members
checked
Get the value of the checked attribute for first element in the set of matched elements or set the value of every matched element.
data
Get the data attributes of the first element in the set of matched elements. If value can be turned into a Number it will be (eg. {'position': 2, 'name': 'foo'}).
firstNode
First element in the set of matched elements.
html
Get the HTML contents of the first element in the set of matched elements or set the HTML contents of every matched element.
length
Length of the set of matched elements.
nodeList
List of matched elements.
text
Get the text contents of the first element in the set of matched elements or set the text contents of every matched element.
val
Get the value of the first element in the set of matched elements or set the value of every matched element.
Methods
addClass(className) → {Query}
Add a class to the set of matched elements.
Parameters:
Name | Type | Description |
---|---|---|
className |
string | The value of the class to add. |
Returns:
- Type
- Query
append(content) → {Query}
Insert content, specified by the parameter, to the end of each element in the set of matched elements.
Parameters:
Name | Type | Description |
---|---|---|
content |
string | HTML string. |
Returns:
- Type
- Query
css(name, value) → {Query}
Set a CSS property for every matched element.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | A CSS property name. |
value |
string | A value to set for the property. |
Returns:
- Type
- Query
empty() → {Query}
Remove all child nodes of the set of matched elements from the DOM.
Returns:
- Type
- Query
getAttr(name) → {string}
Get the value of an attribute for the first element in the set of matched elements.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name of the attribute to get. |
Returns:
- Type
- string
hasClass(className) → {boolean}
Checks if the specified class value exists in the set of matched elements. If any element contains the class, will return true.
Parameters:
Name | Type | Description |
---|---|---|
className |
string | The value of the class to check. |
Returns:
- Type
- boolean
off(type, listener) → {Query}
Remove an event handler function for one event to the selected elements.
Parameters:
Name | Type | Description |
---|---|---|
type |
string | The name of the event to listen on. |
listener |
function | The callback function for when this event is triggered. |
Returns:
- Type
- Query
on(type, listener) → {Query}
Attach an event handler function for one event to the selected elements.
Parameters:
Name | Type | Description |
---|---|---|
type |
string | The name of the event to listen on. |
listener |
function | The callback function for when this event is triggered. |
Returns:
- Type
- Query
prepend(content) → {Query}
Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.
Parameters:
Name | Type | Description |
---|---|---|
content |
string | HTML string. |
Returns:
- Type
- Query
remove() → {Query}
Remove the set of matched elements from the DOM.
Returns:
- Type
- Query
removeAttr(name) → {Query}
Remove an attribute from each element in the set of matched elements.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | An attribute to remove. |
Returns:
- Type
- Query
removeClass(className) → {Query}
Remove a class from the set of matched elements.
Parameters:
Name | Type | Description |
---|---|---|
className |
string | The value of the class to remove. |
Returns:
- Type
- Query
setAttr(name, value) → {Query}
Set an attribute for every matched element.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name of the attribute to set. |
value |
string | A value to set for the attribute. |
Returns:
- Type
- Query
stringToElement(content) → {NodeList}
Convert HTML string to a NodeList.
Parameters:
Name | Type | Description |
---|---|---|
content |
string | HTML string. |
Returns:
- Type
- NodeList
toggleClass(className) → {boolean}
Toggle the class value on the set of matched elements.
Parameters:
Name | Type | Description |
---|---|---|
className |
string | The value of the class to toggle. |
Returns:
- Type
- boolean