tinymce.dom.DomQuery
This class mimics most of the jQuery API: This is whats currently implemented: - Utility functions - DOM traversial - DOM manipulation - Event binding This is not currently implemented: - Dimension - Ajax - Animation - Advanced chaining
DomQuery has been deprecated in TinyMCE 5.10 and has been marked for removal in TinyMCE 6.0.
Summary
Properties
Name | Type | Summary | Defined by |
---|---|---|---|
context |
|
Context used to create the set. |
|
length |
|
Number of items in the current set. |
|
selector |
|
Selector for the current set. |
Constructors
Name | Summary | Defined by |
---|---|---|
Constructs a new DomQuery instance with the specified selector or context. |
Methods
Name | Summary | Defined by |
---|---|---|
Adds new nodes to the set. |
||
Adds the specified class name to the current set elements. |
||
Adds the specified elements after current set nodes. |
||
Appends the specified node/html or node set to the current set nodes. |
||
Appends the specified set nodes to the specified selector/instance. |
||
Sets/gets properties on the elements in the current set. |
||
Adds the specified elements before current set nodes. |
||
Returns all child elements matching the optional selector. |
||
Clones all nodes in set. |
||
Gets the current node or any parent matching the specified selector. |
||
Returns all child nodes matching the optional selector. |
||
Sets/gets styles on the elements in the current set. |
||
Executes the callback function for each item DomQuery collection. If you return false in the callback it will break the loop. |
||
Executes the callback function for each item in array/object. If you return false in the callback it will break the loop. |
||
Empties all elements in set. |
||
Makes the set equal to the specified index. |
||
Extends the specified object with one or more objects. |
||
Filters the current set with the specified selector. |
||
Finds elements by the specified selector for each element in set. |
||
Makes the set equal to first element in set. |
||
Filters out items from the input array by calling the specified function for each item. If the function returns false the item will be excluded if it returns true it will be included. |
||
Returns true/false if the first item in set has the specified class. |
||
Hides all elements in set. |
||
Sets or gets the HTML of the current set or first set node. |
||
Returns the index of the specified item inside the array. |
||
Returns true/false if the current set items matches the selector. |
||
Returns true/false if the specified object is an array or not. |
||
Makes the set equal to last element in set. |
||
Creates an array out of an array like object. |
||
Returns a new collection with next sibling of each item in current collection matching the optional selector. |
||
Returns a new collection with all next siblings of each item in current collection matching the optional selector. |
||
Unbinds an event with callback function to the elements in set. |
||
Returns the offset of the first element in set or sets the top/left css properties of all elements in set. |
||
Binds an event with callback function to the elements in set. |
||
Returns a new collection with the parent of each item in current collection matching the optional selector. |
||
Returns a new collection with the all the parents of each item in current collection matching the optional selector. |
||
Returns a new collection with the all the parents until the matching selector/element of each item in current collection matching the optional selector. |
||
Prepends the specified node/html or node set to the current set nodes. |
||
Prepends the specified set nodes to the specified selector/instance. |
||
Returns a new collection with previous sibling of each item in current collection matching the optional selector. |
||
Returns a new collection with all previous siblings of each item in current collection matching the optional selector. |
||
Removes all nodes in set from the document. |
||
Removes attributse on the elements in the current set. |
||
Removes the specified class name to the current set elements. |
||
Replaces the nodes in set with the specified content. |
||
Shows all elements in set. |
||
Slices the current set. |
||
Sets or gets the text of the current set or first set node. |
||
Converts the current set to an array. |
||
Toggles the specified class name on the current set elements. |
||
Triggers the specified event by name or event object. |
||
Removes whitespace from the beginning and end of a string. |
||
Unwraps all elements by removing the parent element of each item in set. |
||
Wraps all elements in set with the specified wrapper. |
||
Wraps all nodes in set with the specified wrapper. If the nodes are siblings all of them will be wrapped in the same wrapper. |
||
Wraps all elements inner contents in set with the specified wrapper. |
Constructors
Methods
add()
add(items: Array | tinymce.core.dom.DomQuery, sort: Boolean): tinymce.dom.DomQuery
Adds new nodes to the set.
Parameters
-
items (Array | DomQuery)
- Array of all nodes to add to set. -
sort (Boolean)
- Optional sort flag that enables sorting of elements.
addClass()
addClass(className: String): tinymce.dom.DomQuery
Adds the specified class name to the current set elements.
after()
after(content: String | Element | Array | tinymce.dom.DomQuery): tinymce.dom.DomQuery
Adds the specified elements after current set nodes.
Parameters
-
content (String | Element | Array | DomQuery)
- Content to add after to each element in set.
append()
append(content: String | Element | Array | tinymce.dom.DomQuery): tinymce.dom.DomQuery
Appends the specified node/html or node set to the current set nodes.
Parameters
-
content (String | Element | Array | DomQuery)
- Content to append to each element in set.
appendTo()
appendTo(val: String | Element | Array | tinymce.dom.DomQuery): tinymce.dom.DomQuery
Appends the specified set nodes to the specified selector/instance.
Parameters
-
val (String | Element | Array | DomQuery)
- Item to append the current set to.
attr()
attr(name: String | Object, value: String): tinymce.dom.DomQuery | String
Sets/gets properties on the elements in the current set.
Parameters
-
name (String | Object)
- Name of property to get or an object with properties to set. -
value (String)
- Optional value to set.
Return value
-
DomQuery
- Current set or the specified property when only the name is specified. -
String
- Current set or the specified property when only the name is specified.
before()
before(content: String | Element | Array | tinymce.dom.DomQuery): tinymce.dom.DomQuery
Adds the specified elements before current set nodes.
Parameters
-
content (String | Element | Array | DomQuery)
- Content to add before to each element in set.
children()
children(node: Element | tinymce.dom.DomQuery): tinymce.dom.DomQuery
Returns all child elements matching the optional selector.
Parameters
-
node (Element | DomQuery)
- Node to match the elements against.
closest()
closest(selector: String | Element | tinymce.dom.DomQuery): tinymce.dom.DomQuery
Gets the current node or any parent matching the specified selector.
Parameters
-
selector (String | Element | DomQuery)
- Selector or element to find.
contents()
contents(node: Element | tinymce.dom.DomQuery): tinymce.dom.DomQuery
Returns all child nodes matching the optional selector.
Parameters
-
node (Element | DomQuery)
- Node to get the contents of.
css()
css(name: String | Object, value: String): tinymce.dom.DomQuery | String
Sets/gets styles on the elements in the current set.
Parameters
-
name (String | Object)
- Name of style to get or an object with styles to set. -
value (String)
- Optional value to set.
Return value
-
DomQuery
- Current set or the specified style when only the name is specified. -
String
- Current set or the specified style when only the name is specified.
each()
each(callback: function): tinymce.dom.DomQuery
Executes the callback function for each item DomQuery collection. If you return false in the callback it will break the loop.
each()
each(obj: Object, callback: function)
Executes the callback function for each item in array/object. If you return false in the callback it will break the loop.
extend()
extend(target: Object, object: Object..): Object
Extends the specified object with one or more objects.
filter()
filter(selector: String | function): tinymce.dom.DomQuery
Filters the current set with the specified selector.
find()
find(selector: String): tinymce.dom.DomQuery
Finds elements by the specified selector for each element in set.
grep()
grep(array: Array, callback: function): Array
Filters out items from the input array by calling the specified function for each item. If the function returns false the item will be excluded if it returns true it will be included.
Examples
// Filter out some items, this will return an array with 4 and 5
var items = DomQueryBuilder.grep([1, 2, 3, 4, 5], function(v) {return v > 3;});
hasClass()
hasClass(className: String): Boolean
Returns true/false if the first item in set has the specified class.
html()
html(value: String): tinymce.dom.DomQuery | String
Sets or gets the HTML of the current set or first set node.
Return value
-
DomQuery
- Current set or the innerHTML of the first element. -
String
- Current set or the innerHTML of the first element.
inArray()
inArray(item: Object, array: Array): Number
Returns the index of the specified item inside the array.
is()
is(selector: String): Boolean
Returns true/false if the current set items matches the selector.
isArray()
isArray(array: Object): Boolean
Returns true/false if the specified object is an array or not.
next()
next(node: Element | tinymce.dom.DomQuery): tinymce.dom.DomQuery
Returns a new collection with next sibling of each item in current collection matching the optional selector.
Parameters
-
node (Element | DomQuery)
- Node to match the next element against.
nextUntil()
nextUntil(node: Element | tinymce.dom.DomQuery, until: String | Element | tinymce.dom.DomQuery): tinymce.dom.DomQuery
Returns a new collection with all next siblings of each item in current collection matching the optional selector.
off()
off(name: String, callback: function): tinymce.dom.DomQuery
Unbinds an event with callback function to the elements in set.
offset()
offset(offset: Object): Object | tinymce.dom.DomQuery
Returns the offset of the first element in set or sets the top/left css properties of all elements in set.
Return value
-
Object
- Returns the first element offset or the current set if you specified an offset. -
DomQuery
- Returns the first element offset or the current set if you specified an offset.
on()
on(name: String, callback: function): tinymce.dom.DomQuery
Binds an event with callback function to the elements in set.
parent()
parent(node: Element | tinymce.dom.DomQuery): tinymce.dom.DomQuery
Returns a new collection with the parent of each item in current collection matching the optional selector.
Parameters
-
node (Element | DomQuery)
- Node to match parents against.
parents()
parents(node: Element | tinymce.dom.DomQuery): tinymce.dom.DomQuery
Returns a new collection with the all the parents of each item in current collection matching the optional selector.
Parameters
-
node (Element | DomQuery)
- Node to match parents against.
parentsUntil()
parentsUntil(node: Element | tinymce.dom.DomQuery, until: String | Element | tinymce.dom.DomQuery): tinymce.dom.DomQuery
Returns a new collection with the all the parents until the matching selector/element of each item in current collection matching the optional selector.
prepend()
prepend(content: String | Element | Array | tinymce.dom.DomQuery): tinymce.dom.DomQuery
Prepends the specified node/html or node set to the current set nodes.
Parameters
-
content (String | Element | Array | DomQuery)
- Content to prepend to each element in set.
prependTo()
prependTo(val: String | Element | Array | tinymce.dom.DomQuery): tinymce.dom.DomQuery
Prepends the specified set nodes to the specified selector/instance.
Parameters
-
val (String | Element | Array | DomQuery)
- Item to prepend the current set to.
prev()
prev(node: Element | tinymce.dom.DomQuery): tinymce.dom.DomQuery
Returns a new collection with previous sibling of each item in current collection matching the optional selector.
Parameters
-
node (Element | DomQuery)
- Node to match the previous element against.
prevUntil()
prevUntil(node: Element | tinymce.dom.DomQuery, until: String | Element | tinymce.dom.DomQuery): tinymce.dom.DomQuery
Returns a new collection with all previous siblings of each item in current collection matching the optional selector.
removeAttr()
removeAttr(name: String | Object): tinymce.dom.DomQuery | String
Removes attributse on the elements in the current set.
removeClass()
removeClass(className: String): tinymce.dom.DomQuery
Removes the specified class name to the current set elements.
replaceWith()
replaceWith(content: String | Element | Array | tinymce.dom.DomQuery): tinymce.dom.DomQuery
Replaces the nodes in set with the specified content.
Parameters
-
content (String | Element | Array | DomQuery)
- Content to replace nodes with.
slice()
slice(start: Number, end: Number): tinymce.dom.DomQuery
Slices the current set.
text()
text(value: String): tinymce.dom.DomQuery | String
Sets or gets the text of the current set or first set node.
Return value
-
DomQuery
- Current set or the innerText of the first element. -
String
- Current set or the innerText of the first element.
toggleClass()
toggleClass(className: String, state: Boolean): tinymce.dom.DomQuery
Toggles the specified class name on the current set elements.
trigger()
trigger(name: String | Object): tinymce.dom.DomQuery
Triggers the specified event by name or event object.
unwrap()
unwrap(): tinymce.dom.DomQuery
Unwraps all elements by removing the parent element of each item in set.
wrap()
wrap(content: String | Element | Array | tinymce.dom.DomQuery): tinymce.dom.DomQuery
Wraps all elements in set with the specified wrapper.
Parameters
-
content (String | Element | Array | DomQuery)
- Content to wrap nodes with.
wrapAll()
wrapAll(content: String | Element | Array | tinymce.dom.DomQuery): tinymce.dom.DomQuery
Wraps all nodes in set with the specified wrapper. If the nodes are siblings all of them will be wrapped in the same wrapper.
Parameters
-
content (String | Element | Array | DomQuery)
- Content to wrap nodes with.
wrapInner()
wrapInner(content: String | Element | Array | tinymce.dom.DomQuery): tinymce.dom.DomQuery
Wraps all elements inner contents in set with the specified wrapper.
Parameters
-
content (String | Element | Array | DomQuery)
- Content to wrap nodes with.