tinymce.dom.DOMUtils
Utility class for various DOM manipulation and retrieval functions.
Examples
// Add a class to an element by id in the page
tinymce.DOM.addClass('someid', 'someclass');
// Add a class to an element by id inside the editor
tinymce.activeEditor.dom.addClass('someid', 'someclass');
Properties
name | type | summary | defined by |
---|---|---|---|
$ | tinymce.dom.DomQuery | Deprecated in TinyMCE 5.10 and has been marked for removal in TinyMCE 6.0. | tinymce.dom.DOMUtils |
$$ | tinymce.dom.DomQuery | Deprecated in TinyMCE 5.10 and has been marked for removal in TinyMCE 6.0. | tinymce.dom.DOMUtils |
DOM | tinymce.dom.DOMUtils | Instance of DOMUtils for the current document. | tinymce.dom.DOMUtils |
Methods
name | summary | defined by |
---|---|---|
add() | Adds the specified element to another element or elements. | tinymce.dom.DOMUtils |
addClass() | Adds a class to the specified element or elements. | tinymce.dom.DOMUtils |
addStyle() | Adds a style element at the top of the document with the specified cssText content. | tinymce.dom.DOMUtils |
bind() | Adds an event handler to the specified object. | tinymce.dom.DOMUtils |
create() | Creates a new element. | tinymce.dom.DOMUtils |
createFragment() | Creates a document fragment out of the specified HTML string. | tinymce.dom.DOMUtils |
createHTML() | Creates HTML string for element. The element will be closed unless an empty inner HTML string is passed in. | tinymce.dom.DOMUtils |
createRng() | Creates a new DOM Range object. This will use the native DOM Range API if it's available. If it's not, it will fall back to the custom TinyMCE implementation. | tinymce.dom.DOMUtils |
decode() | Entity decodes a string. This method decodes any HTML entities, such as å. | tinymce.dom.DOMUtils |
destroy() | Destroys all internal references to the DOM to solve IE leak issues. | tinymce.dom.DOMUtils |
encode() | Entity encodes a string. This method encodes the most common entities, such as <>"&. | tinymce.dom.DOMUtils |
findCommonAncestor() | Find the common ancestor of two elements. This is a shorter method than using the DOM Range logic. | tinymce.dom.DOMUtils |
fire() | Fires the specified event name with object on target. | tinymce.dom.DOMUtils |
get() | Returns the specified element by ID or the input element if it isn't a string. | tinymce.dom.DOMUtils |
getAttrib() | Returns the specified attribute by name. | tinymce.dom.DOMUtils |
getAttribs() | Returns a NodeList with attributes for the element. | tinymce.dom.DOMUtils |
getNext() | Returns the next node that matches selector or function | tinymce.dom.DOMUtils |
getOuterHTML() | Returns the outer HTML of an element. | tinymce.dom.DOMUtils |
getParent() | Returns a node by the specified selector function. This function will loop through all parent nodes and call the specified function for each node. If the function then returns true indicating that it has found what it was looking for, the loop execution will then end and the node it found will be returned. | tinymce.dom.DOMUtils |
getParents() | Returns a node list of all parents matching the specified selector function or pattern. If the function then returns true indicating that it has found what it was looking for and that node will be collected. | tinymce.dom.DOMUtils |
getPos() | Returns the absolute x, y position of a node. The position will be returned in an object with x, y fields. | tinymce.dom.DOMUtils |
getPrev() | Returns the previous node that matches selector or function | tinymce.dom.DOMUtils |
getRect() | Returns the rectangle for a specific element. | tinymce.dom.DOMUtils |
getRoot() | Returns the root node of the document. This is normally the body but might be a DIV. Parents like getParent will not go above the point of this root node. | tinymce.dom.DOMUtils |
getSize() | Returns the size dimensions of the specified element. | tinymce.dom.DOMUtils |
getStyle() | Returns the current style or runtime/computed value of an element. | tinymce.dom.DOMUtils |
getViewPort() | Returns the viewport of the window. | tinymce.dom.DOMUtils |
hasClass() | Returns true if the specified element has the specified class. | tinymce.dom.DOMUtils |
hide() | Hides the specified element(s) by ID by setting the "display" style. | tinymce.dom.DOMUtils |
insertAfter() | Inserts an element after the reference element. | tinymce.dom.DOMUtils |
is() | Returns true/false if the specified element matches the specified css pattern. | tinymce.dom.DOMUtils |
isBlock() | Returns true/false if the specified element is a block element or not. | tinymce.dom.DOMUtils |
isEmpty() | Returns true/false if the specified node is to be considered empty or not. | tinymce.dom.DOMUtils |
isHidden() | Returns true/false if the element is hidden or not by checking the "display" style. | tinymce.dom.DOMUtils |
loadCSS() | Imports/loads the specified CSS file into the document bound to the class. | tinymce.dom.DOMUtils |
nodeIndex() | Returns the index of the specified node within its parent. | tinymce.dom.DOMUtils |
parseStyle() | Parses the specified style value into an object collection. This parser will also merge and remove any redundant items that browsers might have added. It will also convert non-hex colors to hex values. Urls inside the styles will also be converted to absolute/relative based on settings. | tinymce.dom.DOMUtils |
remove() | Removes/deletes the specified element(s) from the DOM. | tinymce.dom.DOMUtils |
removeAllAttribs() | Removes all attributes from an element or elements. | tinymce.dom.DOMUtils |
removeClass() | Removes a class from the specified element or elements. | tinymce.dom.DOMUtils |
rename() | Renames the specified element and keeps its attributes and children. | tinymce.dom.DOMUtils |
replace() | Replaces the specified element or elements with the new element specified. The new element will be cloned if multiple input elements are passed in. | tinymce.dom.DOMUtils |
run() | Executes the specified function on the element by id or dom element node or array of elements/id. | tinymce.dom.DOMUtils |
select() | Returns a list of the elements specified by the given CSS selector. For example "div#a1 p.test". This function is optimized for the most common patterns needed in TinyMCE but it also performs well enough on more complex patterns. | tinymce.dom.DOMUtils |
serializeStyle() | Serializes the specified style object into a string. | tinymce.dom.DOMUtils |
setAttrib() | Sets the specified attribute of an element or elements. | tinymce.dom.DOMUtils |
setAttribs() | Sets two or more specified attributes of an element or elements. | tinymce.dom.DOMUtils |
setHTML() | Sets the specified HTML content inside the element or elements. The HTML will first be processed. This means URLs will get converted, hex color values fixed etc. Check processHTML for details. | tinymce.dom.DOMUtils |
setOuterHTML() | Sets the specified outer HTML on an element or elements. | tinymce.dom.DOMUtils |
setStyle() | Sets the CSS style value on a HTML element. The name can be a camelcase string or the CSS style name like background-color. | tinymce.dom.DOMUtils |
setStyles() | Sets multiple styles on the specified element(s). | tinymce.dom.DOMUtils |
show() | Shows the specified element(s) by ID by setting the "display" style. | tinymce.dom.DOMUtils |
split() | Splits an element into two new elements and places the specified split element or elements between the new ones. For example splitting the paragraph at the bold element in this example abcabc123 would produceabc abc123 . | tinymce.dom.DOMUtils |
toHex() | Parses the specified RGB color value and returns a hex version of that color. | tinymce.dom.DOMUtils |
toggleClass() | Toggles the specified class on/off. | tinymce.dom.DOMUtils |
unbind() | Removes the specified event handler by name and function from an element or collection of elements. | tinymce.dom.DOMUtils |
uniqueId() | Returns a unique id. This can be useful when generating elements on the fly. This method will not check if the element already exists. | tinymce.dom.DOMUtils |
Methods
add
Adds the specified element to another element or elements.
Examples
// Adds a new paragraph to the end of the active editor
tinymce.activeEditor.dom.add(tinymce.activeEditor.getBody(), 'p', {title: 'my title'}, 'Some content');
Parameters
- parentElm (String) - Element id string, DOM node element or array of ids or elements to add to.
- name (String) - Name of new element to add or existing element to add.
- attrs (Object) - Optional object collection with arguments to add to the new element(s).
- html (String) - Optional inner HTML contents to add for each element.
- create (Boolean) - Optional flag if the element should be created or added.
Return value
- Element - Element that got created, or an array of created elements if multiple input elements were passed in.
- Array - Element that got created, or an array of created elements if multiple input elements were passed in.
addClass
Adds a class to the specified element or elements.
Examples
// Adds a class to all paragraphs in the active editor
tinymce.activeEditor.dom.addClass(tinymce.activeEditor.dom.select('p'), 'myclass');
// Adds a class to a specific element in the current page
tinymce.DOM.addClass('mydiv', 'myclass');
Parameters
- elm (String) - Element ID string or DOM element or array with elements or IDs.
- cls (String) - Class name to add to each element.
Return value
- String - String with new class value or array with new class values for all elements.
- Array - String with new class value or array with new class values for all elements.
addStyle
Adds a style element at the top of the document with the specified cssText content.
Parameters
- cssText (String) - CSS Text style to add to top of head of document.
bind
Adds an event handler to the specified object.
Parameters
- target (Element) - Target element to bind events to. handler to or an array of elements/ids/documents.
- name (String) - Name of event handler to add, for example: click.
- func (function) - Function to execute when the event occurs.
- scope (Object) - Optional scope to execute the function in.
Return value
- function - Function callback handler the same as the one passed in.
create
Creates a new element.
Examples
// Adds an element where the caret/selection is in the active editor
var el = tinymce.activeEditor.dom.create('div', {id: 'test', 'class': 'myclass'}, 'some content');
tinymce.activeEditor.selection.setNode(el);
Parameters
- name (String) - Name of new element.
- attrs (Object) - Optional object name/value collection with element attributes.
- html (String) - Optional HTML string to set as inner HTML of the element.
Return value
- Element - HTML DOM node element that got created.
createFragment
Creates a document fragment out of the specified HTML string.
Parameters
- html (String) - Html string to create fragment from.
Return value
- DocumentFragment - Document fragment node.
createHTML
Creates HTML string for element. The element will be closed unless an empty inner HTML string is passed in.
Examples
// Creates a html chunk and inserts it at the current selection/caret location
tinymce.activeEditor.selection.setContent(tinymce.activeEditor.dom.createHTML('a', {href: 'test.html'}, 'some line'));
Parameters
- name (String) - Name of new element.
- attrs (Object) - Optional object name/value collection with element attributes.
- html (String) - Optional HTML string to set as inner HTML of the element.
Return value
- String - String with new HTML element, for example: test.
createRng
Creates a new DOM Range object. This will use the native DOM Range API if it's available. If it's not, it will fall back to the custom TinyMCE implementation.
Examples
var rng = tinymce.DOM.createRng();
alert(rng.startContainer + "," + rng.startOffset);
Return value
- DOMRange - DOM Range object.
decode
Entity decodes a string. This method decodes any HTML entities, such as å.
Parameters
- s (String) - String to decode entities on.
Return value
- String - Entity decoded string.
destroy
Destroys all internal references to the DOM to solve IE leak issues.
encode
Entity encodes a string. This method encodes the most common entities, such as <>"&.
Parameters
- text (String) - String to encode with entities.
Return value
- String - Entity encoded string.
findCommonAncestor
Find the common ancestor of two elements. This is a shorter method than using the DOM Range logic.
Parameters
- a (Element) - Element to find common ancestor of.
- b (Element) - Element to find common ancestor of.
Return value
- Element - Common ancestor element of the two input elements.
fire
Fires the specified event name with object on target.
Parameters
- target (Node) - Target element or object to fire event on.
- name (String) - Name of the event to fire.
- evt (Object) - Event object to send.
Return value
- Event - Event object.
get
Returns the specified element by ID or the input element if it isn't a string.
Parameters
- n (String) - Element id to look for or element to just pass though.
Return value
- Element - Element matching the specified id or null if it wasn't found.
getAttrib
Returns the specified attribute by name.
Parameters
- elm (String) - Element string id or DOM element to get attribute from.
- name (String) - Name of attribute to get.
- defaultVal (String) - Optional default value to return if the attribute didn't exist.
Return value
- String - Attribute value string, default value or null if the attribute wasn't found.
getAttribs
Returns a NodeList with attributes for the element.
Parameters
- elm (HTMLElement) - Element node or string id to get attributes from.
Return value
- NodeList - NodeList with attributes.
getNext
Returns the next node that matches selector or function
Parameters
- node (Node) - Node to find siblings from.
- selector (String) - Selector CSS expression or function.
Return value
- Node - Next node item matching the selector or null if it wasn't found.
getOuterHTML
Returns the outer HTML of an element.
Examples
tinymce.DOM.getOuterHTML(editorElement);
tinymce.activeEditor.getOuterHTML(tinymce.activeEditor.getBody());
Parameters
- elm (String) - Element ID or element object to get outer HTML from.
Return value
- String - Outer HTML string.
getParent
Returns a node by the specified selector function. This function will loop through all parent nodes and call the specified function for each node. If the function then returns true indicating that it has found what it was looking for, the loop execution will then end and the node it found will be returned.
Parameters
- node (Node) - DOM node to search parents on or ID string.
- selector (function) - Selection function or CSS selector to execute on each node.
- root (Node) - Optional root element, never go beyond this point.
Return value
- Node - DOM Node or null if it wasn't found.
getParents
Returns a node list of all parents matching the specified selector function or pattern. If the function then returns true indicating that it has found what it was looking for and that node will be collected.
Parameters
- node (Node) - DOM node to search parents on or ID string.
- selector (function) - Selection function to execute on each node or CSS pattern.
- root (Node) - Optional root element, never go beyond this point.
Return value
- Array - Array of nodes or null if it wasn't found.
getPos
Returns the absolute x, y position of a node. The position will be returned in an object with x, y fields.
Parameters
- elm (Element) - HTML element or element id to get x, y position from.
- rootElm (Element) - Optional root element to stop calculations at.
Return value
- object - Absolute position of the specified element object with x, y fields.
getPrev
Returns the previous node that matches selector or function
Parameters
- node (Node) - Node to find siblings from.
- selector (String) - Selector CSS expression or function.
Return value
- Node - Previous node item matching the selector or null if it wasn't found.
getRect
Returns the rectangle for a specific element.
Parameters
- elm (Element) - Element object or element ID to get rectangle from.
Return value
- object - Rectangle for specified element object with x, y, w, h fields.
getRoot
Returns the root node of the document. This is normally the body but might be a DIV. Parents like getParent will not go above the point of this root node.
Return value
- Element - Root element for the utility class.
getSize
Returns the size dimensions of the specified element.
Parameters
- elm (Element) - Element object or element ID to get rectangle from.
Return value
- object - Rectangle for specified element object with w, h fields.
getStyle
Returns the current style or runtime/computed value of an element.
Parameters
- elm (String) - HTML element or element id string to get style from.
- name (String) - Style name to return.
- computed (Boolean) - Computed style.
Return value
- String - Current style or computed style value of an element.
getViewPort
Returns the viewport of the window.
Parameters
- win (Window) - Optional window to get viewport of.
Return value
- Object - Viewport object with fields x, y, w and h.
hasClass
Returns true if the specified element has the specified class.
Parameters
- elm (String) - HTML element or element id string to check CSS class on.
- cls (String) - CSS class to check for.
Return value
- Boolean - true/false if the specified element has the specified class.
hide
Hides the specified element(s) by ID by setting the "display" style.
Examples
// Hides an element by id in the document
tinymce.DOM.hide('myid');
Parameters
- elm (String) - ID of DOM element or DOM element or array with elements or IDs to hide.
insertAfter
Inserts an element after the reference element.
Parameters
- node (Element) - Element to insert after the reference.
- referenceNode (Element) - Reference element, element id or array of elements to insert after.
Return value
- Element - Element that got added or an array with elements.
- Array - Element that got added or an array with elements.
is
Returns true/false if the specified element matches the specified css pattern.
Parameters
- elm (Node) - DOM node to match or an array of nodes to match.
- selector (String) - CSS pattern to match the element against.
isBlock
Returns true/false if the specified element is a block element or not.
Parameters
- node (Node) - Element/Node to check.
Return value
- Boolean - True/False state if the node is a block element or not.
isEmpty
Returns true/false if the specified node is to be considered empty or not.
Examples
tinymce.DOM.isEmpty(node, {img: true});
Parameters
- elements (Object) - Optional name/value object with elements that are automatically treated as non-empty elements.
Return value
- Boolean - true/false if the node is empty or not.
isHidden
Returns true/false if the element is hidden or not by checking the "display" style.
Parameters
- elm (String) - Id or element to check display state on.
Return value
- Boolean - true/false if the element is hidden or not.
loadCSS
Imports/loads the specified CSS file into the document bound to the class.
Examples
// Loads a CSS file dynamically into the current document
tinymce.DOM.loadCSS('somepath/some.css');
// Loads a CSS file into the currently active editor instance
tinymce.activeEditor.dom.loadCSS('somepath/some.css');
// Loads a CSS file into an editor instance by id
tinymce.get('someid').dom.loadCSS('somepath/some.css');
// Loads multiple CSS files into the current document
tinymce.DOM.loadCSS('somepath/some.css,somepath/someother.css');
Parameters
- url (String) - URL to CSS file to load.
nodeIndex
Returns the index of the specified node within its parent.
Parameters
- node (Node) - Node to look for.
- normalized (boolean) - Optional true/false state if the index is what it would be after a normalization.
Return value
- Number - Index of the specified node.
parseStyle
Parses the specified style value into an object collection. This parser will also merge and remove any redundant items that browsers might have added. It will also convert non-hex colors to hex values. Urls inside the styles will also be converted to absolute/relative based on settings.
Parameters
- cssText (String) - Style value to parse, for example: border:1px solid red;.
Return value
- Object - Object representation of that style, for example: {border: '1px solid red'}
remove
Removes/deletes the specified element(s) from the DOM.
Examples
// Removes all paragraphs in the active editor
tinymce.activeEditor.dom.remove(tinymce.activeEditor.dom.select('p'));
// Removes an element by id in the document
tinymce.DOM.remove('mydiv');
Parameters
- node (String) - ID of element or DOM element object or array containing multiple elements/ids.
- keepChildren (Boolean) - Optional state to keep children or not. If set to true all children will be placed at the location of the removed element.
Return value
- Element - HTML DOM element that got removed, or an array of removed elements if multiple input elements were passed in.
- Array - HTML DOM element that got removed, or an array of removed elements if multiple input elements were passed in.
removeAllAttribs
Removes all attributes from an element or elements.
Parameters
- e (Element) - DOM element, element id string or array of elements/ids to remove attributes from.
removeClass
Removes a class from the specified element or elements.
Examples
// Removes a class from all paragraphs in the active editor
tinymce.activeEditor.dom.removeClass(tinymce.activeEditor.dom.select('p'), 'myclass');
// Removes a class from a specific element in the current page
tinymce.DOM.removeClass('mydiv', 'myclass');
Parameters
- elm (String) - Element ID string or DOM element or array with elements or IDs.
- cls (String) - Class name to remove from each element.
Return value
- String - String of remaining class name(s), or an array of strings if multiple input elements were passed in.
- Array - String of remaining class name(s), or an array of strings if multiple input elements were passed in.
rename
Renames the specified element and keeps its attributes and children.
Parameters
- elm (Element) - Element to rename.
- name (String) - Name of the new element.
Return value
- Element - New element or the old element if it needed renaming.
replace
Replaces the specified element or elements with the new element specified. The new element will be cloned if multiple input elements are passed in.
Parameters
- newElm (Element) - New element to replace old ones with.
- oldElm (Element) - Element DOM node, element id or array of elements or ids to replace.
- keepChildren (Boolean) - Optional keep children state, if set to true child nodes from the old object will be added to new ones.
run
Executes the specified function on the element by id or dom element node or array of elements/id.
Parameters
- elm (String) - ID or DOM element object or array with ids or elements.
- func (function) - Function to execute for each item.
- scope (Object) - Optional scope to execute the function in.
Return value
- Object - Single object, or an array of objects if multiple input elements were passed in.
- Array - Single object, or an array of objects if multiple input elements were passed in.
select
Returns a list of the elements specified by the given CSS selector. For example "div#a1 p.test". This function is optimized for the most common patterns needed in TinyMCE but it also performs well enough on more complex patterns.
Examples
// Adds a class to all paragraphs in the currently active editor
tinymce.activeEditor.dom.addClass(tinymce.activeEditor.dom.select('p'), 'someclass');
// Adds a class to all spans that have the test class in the currently active editor
tinymce.activeEditor.dom.addClass(tinymce.activeEditor.dom.select('span.test'), 'someclass')
Parameters
- selector (String) - Target CSS selector.
- scope (Object) - Optional root element/scope element to search in.
Return value
- Array - Array with all matched elements.
serializeStyle
Serializes the specified style object into a string.
Parameters
- styles (Object) - Object to serialize as string, for example: {border: '1px solid red'}
- name (String) - Optional element name.
Return value
- String - String representation of the style object, for example: border: 1px solid red.
setAttrib
Sets the specified attribute of an element or elements.
Examples
// Sets class attribute on all paragraphs in the active editor
tinymce.activeEditor.dom.setAttrib(tinymce.activeEditor.dom.select('p'), 'class', 'myclass');
// Sets class attribute on a specific element in the current page
tinymce.dom.setAttrib('mydiv', 'class', 'myclass');
Parameters
- elm (Element) - DOM element, element id string or array of elements/ids to set attribute on.
- name (String) - Name of attribute to set.
- value (String) - Value to set on the attribute - if this value is falsy like null, 0 or '' it will remove the attribute instead.
setAttribs
Sets two or more specified attributes of an element or elements.
Examples
// Sets class and title attributes on all paragraphs in the active editor
tinymce.activeEditor.dom.setAttribs(tinymce.activeEditor.dom.select('p'), {'class': 'myclass', title: 'some title'});
// Sets class and title attributes on a specific element in the current page
tinymce.DOM.setAttribs('mydiv', {'class': 'myclass', title: 'some title'});
Parameters
- elm (Element) - DOM element, element id string or array of elements/ids to set attributes on.
- attrs (Object) - Name/Value collection of attribute items to add to the element(s).
setHTML
Sets the specified HTML content inside the element or elements. The HTML will first be processed. This means URLs will get converted, hex color values fixed etc. Check processHTML for details.
Examples
// Sets the inner HTML of all paragraphs in the active editor
tinymce.activeEditor.dom.setHTML(tinymce.activeEditor.dom.select('p'), 'some inner html');
// Sets the inner HTML of an element by id in the document
tinymce.DOM.setHTML('mydiv', 'some inner html');
Parameters
- elm (Element) - DOM element, element id string or array of elements/ids to set HTML inside of.
- html (String) - HTML content to set as inner HTML of the element.
setOuterHTML
Sets the specified outer HTML on an element or elements.
Examples
// Sets the outer HTML of all paragraphs in the active editor
tinymce.activeEditor.dom.setOuterHTML(tinymce.activeEditor.dom.select('p'), '<div>some html</div>');
// Sets the outer HTML of an element by id in the document
tinymce.DOM.setOuterHTML('mydiv', '<div>some html</div>');
Parameters
- elm (Element) - DOM element, element id string or array of elements/ids to set outer HTML on.
- html (Object) - HTML code to set as outer value for the element.
setStyle
Sets the CSS style value on a HTML element. The name can be a camelcase string or the CSS style name like background-color.
Examples
// Sets a style value on all paragraphs in the currently active editor
tinymce.activeEditor.dom.setStyle(tinymce.activeEditor.dom.select('p'), 'background-color', 'red');
// Sets a style value to an element by id in the current document
tinymce.DOM.setStyle('mydiv', 'background-color', 'red');
Parameters
- elm (String) - HTML element/Array of elements to set CSS style value on.
- name (String) - Name of the style value to set.
- value (String) - Value to set on the style.
setStyles
Sets multiple styles on the specified element(s).
Examples
// Sets styles on all paragraphs in the currently active editor
tinymce.activeEditor.dom.setStyles(tinymce.activeEditor.dom.select('p'), {'background-color': 'red', 'color': 'green'});
// Sets styles to an element by id in the current document
tinymce.DOM.setStyles('mydiv', {'background-color': 'red', 'color': 'green'});
Parameters
- elm (Element) - DOM element, element id string or array of elements/ids to set styles on.
- styles (Object) - Name/Value collection of style items to add to the element(s).
show
Shows the specified element(s) by ID by setting the "display" style.
Parameters
- elm (String) - ID of DOM element or DOM element or array with elements or IDs to show.
split
Splits an element into two new elements and places the specified split element or elements between the new ones. For example splitting the paragraph at the bold element in this example
abcabc123
would produceabc
abc123
.Parameters
- parentElm (Element) - Parent element to split.
- splitElm (Element) - Element to split at.
- replacementElm (Element) - Optional replacement element to replace the split element with.
Return value
- Element - Returns the split element or the replacement element if that is specified.
toHex
Parses the specified RGB color value and returns a hex version of that color.
Parameters
- rgbVal (String) - RGB string value like rgb(1,2,3)
Return value
- String - Hex version of that RGB value like #FF00FF.
toggleClass
Toggles the specified class on/off.
Parameters
- elm (Element) - Element to toggle class on.
- cls ([type]) - Class to toggle on/off.
- state ([type]) - Optional state to set.
unbind
Removes the specified event handler by name and function from an element or collection of elements.
Parameters
- target (Element) - Target element to unbind events on.
- name (String) - Event handler name, for example: "click"
- func (function) - Function to remove.
Return value
- bool - Bool state of true if the handler was removed, or an array of states if multiple input elements were passed in.
- Array - Bool state of true if the handler was removed, or an array of states if multiple input elements were passed in.
uniqueId
Returns a unique id. This can be useful when generating elements on the fly. This method will not check if the element already exists.
Parameters
- prefix (String) - Optional prefix to add in front of all ids - defaults to "mce_".
Return value
- String - Unique id.
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.