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

Examples

var $ = tinymce.dom.DomQuery;
$('p').attr('attr', 'value').addClass('class');

Properties

name type summary defined by
context Element Context used to create the set. tinymce.dom.DomQuery
length Number Number of items in the current set. tinymce.dom.DomQuery
selector String Selector for the current set. tinymce.dom.DomQuery

Constructors

name summary defined by
DomQuery() Constructs a new DomQuery instance with the specified selector or context. tinymce.dom.DomQuery

Methods

name summary defined by
add() Adds new nodes to the set. tinymce.dom.DomQuery
addClass() Adds the specified class name to the current set elements. tinymce.dom.DomQuery
after() Adds the specified elements after current set nodes. tinymce.dom.DomQuery
append() Appends the specified node/html or node set to the current set nodes. tinymce.dom.DomQuery
appendTo() Appends the specified set nodes to the specified selector/instance. tinymce.dom.DomQuery
attr() Sets/gets properties on the elements in the current set. tinymce.dom.DomQuery
before() Adds the specified elements before current set nodes. tinymce.dom.DomQuery
children() Returns all child elements matching the optional selector. tinymce.dom.DomQuery
clone() Clones all nodes in set. tinymce.dom.DomQuery
closest() Gets the current node or any parent matching the specified selector. tinymce.dom.DomQuery
contents() Returns all child nodes matching the optional selector. tinymce.dom.DomQuery
css() Sets/gets styles on the elements in the current set. tinymce.dom.DomQuery
each() Executes the callback function for each item DomQuery collection. If you return false in the callback it will break the loop. tinymce.dom.DomQuery
each() Executes the callback function for each item in array/object. If you return false in the callback it will break the loop. tinymce.dom.DomQuery
empty() Empties all elements in set. tinymce.dom.DomQuery
eq() Makes the set equal to the specified index. tinymce.dom.DomQuery
extend() Extends the specified object with one or more objects. tinymce.dom.DomQuery
filter() Filters the current set with the specified selector. tinymce.dom.DomQuery
find() Finds elements by the specified selector for each element in set. tinymce.dom.DomQuery
first() Makes the set equal to first element in set. tinymce.dom.DomQuery
grep() 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. tinymce.dom.DomQuery
hasClass() Returns true/false if the first item in set has the specified class. tinymce.dom.DomQuery
hide() Hides all elements in set. tinymce.dom.DomQuery
html() Sets or gets the HTML of the current set or first set node. tinymce.dom.DomQuery
inArray() Returns the index of the specified item inside the array. tinymce.dom.DomQuery
is() Returns true/false if the current set items matches the selector. tinymce.dom.DomQuery
isArray() Returns true/false if the specified object is an array or not. tinymce.dom.DomQuery
last() Makes the set equal to last element in set. tinymce.dom.DomQuery
makeArray() Creates an array out of an array like object. tinymce.dom.DomQuery
next() Returns a new collection with next sibling of each item in current collection matching the optional selector. tinymce.dom.DomQuery
nextUntil() Returns a new collection with all next siblings of each item in current collection matching the optional selector. tinymce.dom.DomQuery
off() Unbinds an event with callback function to the elements in set. tinymce.dom.DomQuery
offset() Returns the offset of the first element in set or sets the top/left css properties of all elements in set. tinymce.dom.DomQuery
on() Binds an event with callback function to the elements in set. tinymce.dom.DomQuery
parent() Returns a new collection with the parent of each item in current collection matching the optional selector. tinymce.dom.DomQuery
parents() Returns a new collection with the all the parents of each item in current collection matching the optional selector. tinymce.dom.DomQuery
parentsUntil() Returns a new collection with the all the parents until the matching selector/element of each item in current collection matching the optional selector. tinymce.dom.DomQuery
prepend() Prepends the specified node/html or node set to the current set nodes. tinymce.dom.DomQuery
prependTo() Prepends the specified set nodes to the specified selector/instance. tinymce.dom.DomQuery
prev() Returns a new collection with previous sibling of each item in current collection matching the optional selector. tinymce.dom.DomQuery
prevUntil() Returns a new collection with all previous siblings of each item in current collection matching the optional selector. tinymce.dom.DomQuery
remove() Removes all nodes in set from the document. tinymce.dom.DomQuery
removeAttr() Removes attributse on the elements in the current set. tinymce.dom.DomQuery
removeClass() Removes the specified class name to the current set elements. tinymce.dom.DomQuery
replaceWith() Replaces the nodes in set with the specified content. tinymce.dom.DomQuery
show() Shows all elements in set. tinymce.dom.DomQuery
slice() Slices the current set. tinymce.dom.DomQuery
text() Sets or gets the text of the current set or first set node. tinymce.dom.DomQuery
toArray() Converts the current set to an array. tinymce.dom.DomQuery
toggleClass() Toggles the specified class name on the current set elements. tinymce.dom.DomQuery
trigger() Triggers the specified event by name or event object. tinymce.dom.DomQuery
trim() Removes whitespace from the beginning and end of a string. tinymce.dom.DomQuery
unwrap() Unwraps all elements by removing the parent element of each item in set. tinymce.dom.DomQuery
wrap() Wraps all elements in set with the specified wrapper. tinymce.dom.DomQuery
wrapAll() Wraps all nodes in set with the specified wrapper. If the nodes are siblings all of them will be wrapped in the same wrapper. tinymce.dom.DomQuery
wrapInner() Wraps all elements inner contents in set with the specified wrapper. tinymce.dom.DomQuery

Constructors

DomQuery

public constructor function DomQuery(selector:String, context:Document)

Constructs a new DomQuery instance with the specified selector or context.

Parameters

Methods

add

add(items:Array, sort:Boolean):tinymce.dom.DomQuery

Adds new nodes to the set.

Parameters
Return value

addClass

addClass(className:String):tinymce.dom.DomQuery

Adds the specified class name to the current set elements.

Parameters
Return value

after

after(content:String):tinymce.dom.DomQuery

Adds the specified elements after current set nodes.

Parameters
Return value

append

append(content:String):tinymce.dom.DomQuery

Appends the specified node/html or node set to the current set nodes.

Parameters
Return value

appendTo

appendTo(val:String):tinymce.dom.DomQuery

Appends the specified set nodes to the specified selector/instance.

Parameters
Return value

attr

attr(name:String, value:String):tinymce.dom.DomQuery, String

Sets/gets properties on the elements in the current set.

Parameters
Return value

before

before(content:String):tinymce.dom.DomQuery

Adds the specified elements before current set nodes.

Parameters
Return value

children

children(node:Element):tinymce.dom.DomQuery

Returns all child elements matching the optional selector.

Parameters
Return value

clone

clone():tinymce.dom.DomQuery

Clones all nodes in set.

Return value

closest

closest(selector:String):tinymce.dom.DomQuery

Gets the current node or any parent matching the specified selector.

Parameters
Return value

contents

contents(node:Element):tinymce.dom.DomQuery

Returns all child nodes matching the optional selector.

Parameters
Return value

css

css(name:String, value:String):tinymce.dom.DomQuery, String

Sets/gets styles on the elements in the current set.

Parameters
Return value

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.

Parameters
Return value

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.

Parameters

empty

empty():tinymce.dom.DomQuery

Empties all elements in set.

Return value

eq

eq(index:Number):tinymce.dom.DomQuery

Makes the set equal to the specified index.

Parameters
Return value

extend

extend(target:Object, object:Object..):Object

Extends the specified object with one or more objects.

Parameters
Return value

filter

filter(selector:String):tinymce.dom.DomQuery

Filters the current set with the specified selector.

Parameters
Return value

find

find(selector:String):tinymce.dom.DomQuery

Finds elements by the specified selector for each element in set.

Parameters
Return value

first

first():tinymce.dom.DomQuery

Makes the set equal to first element in set.

Return value

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 = DomQuery.grep([1, 2, 3, 4, 5], function(v) {return v > 3;});
Parameters
Return value

hasClass

hasClass(className:String):Boolean

Returns true/false if the first item in set has the specified class.

Parameters
Return value

hide

hide():tinymce.dom.DomQuery

Hides all elements in set.

Return value

html

html(value:String):tinymce.dom.DomQuery, String

Sets or gets the HTML of the current set or first set node.

Parameters
Return value

inArray

inArray(item:Object, array:Array):Number

Returns the index of the specified item inside the array.

Parameters
Return value

is

is(selector:String):Boolean

Returns true/false if the current set items matches the selector.

Parameters
Return value

isArray

isArray(array:Object):Boolean

Returns true/false if the specified object is an array or not.

Parameters
Return value

last

last():tinymce.dom.DomQuery

Makes the set equal to last element in set.

Return value

makeArray

makeArray(object:Object):Array

Creates an array out of an array like object.

Parameters
Return value

next

next(node:Element):tinymce.dom.DomQuery

Returns a new collection with next sibling of each item in current collection matching the optional selector.

Parameters
Return value

nextUntil

nextUntil(node:Element, until:String):tinymce.dom.DomQuery

Returns a new collection with all next siblings of each item in current collection matching the optional selector.

Parameters
Return value

off

off(name:String, callback:function):tinymce.dom.DomQuery

Unbinds an event with callback function to the elements in set.

Parameters
Return value

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.

Parameters
Return value

on

on(name:String, callback:function):tinymce.dom.DomQuery

Binds an event with callback function to the elements in set.

Parameters
Return value

parent

parent(node:Element):tinymce.dom.DomQuery

Returns a new collection with the parent of each item in current collection matching the optional selector.

Parameters
Return value

parents

parents(node:Element):tinymce.dom.DomQuery

Returns a new collection with the all the parents of each item in current collection matching the optional selector.

Parameters
Return value

parentsUntil

parentsUntil(node:Element, until:String):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.

Parameters
Return value

prepend

prepend(content:String):tinymce.dom.DomQuery

Prepends the specified node/html or node set to the current set nodes.

Parameters
Return value

prependTo

prependTo(val:String):tinymce.dom.DomQuery

Prepends the specified set nodes to the specified selector/instance.

Parameters
Return value

prev

prev(node:Element):tinymce.dom.DomQuery

Returns a new collection with previous sibling of each item in current collection matching the optional selector.

Parameters
Return value

prevUntil

prevUntil(node:Element, until:String):tinymce.dom.DomQuery

Returns a new collection with all previous siblings of each item in current collection matching the optional selector.

Parameters
Return value

remove

remove():tinymce.dom.DomQuery

Removes all nodes in set from the document.

Return value

removeAttr

removeAttr(name:String):tinymce.dom.DomQuery, String

Removes attributse on the elements in the current set.

Parameters
Return value

removeClass

removeClass(className:String):tinymce.dom.DomQuery

Removes the specified class name to the current set elements.

Parameters
Return value

replaceWith

replaceWith(content:String):tinymce.dom.DomQuery

Replaces the nodes in set with the specified content.

Parameters
Return value

show

show():tinymce.dom.DomQuery

Shows all elements in set.

Return value

slice

slice(start:Number, end:Number):tinymce.dom.DomQuery

Slices the current set.

Parameters
Return value

text

text(value:String):tinymce.dom.DomQuery, String

Sets or gets the text of the current set or first set node.

Parameters
Return value

toArray

toArray():Array

Converts the current set to an array.

Return value

toggleClass

toggleClass(className:String, state:Boolean):tinymce.dom.DomQuery

Toggles the specified class name on the current set elements.

Parameters
Return value

trigger

trigger(name:String):tinymce.dom.DomQuery

Triggers the specified event by name or event object.

Parameters
Return value

trim

trim(str:String):String

Removes whitespace from the beginning and end of a string.

Parameters
Return value

unwrap

unwrap():tinymce.dom.DomQuery

Unwraps all elements by removing the parent element of each item in set.

Return value

wrap

wrap(content:String):tinymce.dom.DomQuery

Wraps all elements in set with the specified wrapper.

Parameters
Return value

wrapAll

wrapAll(content:String):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
Return value

wrapInner

wrapInner(content:String):tinymce.dom.DomQuery

Wraps all elements inner contents in set with the specified wrapper.

Parameters
Return value

Can't find what you're looking for? Let us know.

Except as otherwise noted, the content of this page is licensed under the Creative Commons BY-NC-SA 3.0 License, and code samples are licensed under the Apache 2.0 License.