Class CKEDITOR.dom.element
Extends
CKEDITOR.dom.node.
Defined in: core/dom/element.js.
Constructor Attributes | Constructor Name and Description |
---|---|
CKEDITOR.dom.element(element)
Represents a DOM element.
|
Field Attributes | Field Name and Description |
---|---|
The native DOM element represented by this class instance.
|
Method Attributes | Method Name and Description |
---|---|
<static> |
CKEDITOR.dom.element.createFromHtml(html)
Creates an instance of the CKEDITOR.dom.element class based on the
HTML representation of an element.
|
<static> |
CKEDITOR.dom.element.getById(id)
Creates an instance of the CKEDITOR.dom.element class representing an
element with the specific id.
|
<static> |
CKEDITOR.dom.element.getHead()
Creates an instance of the CKEDITOR.dom.element class representing the
<head> element.
|
append(node)
Append a node as a child of this element.
|
|
appendText(text)
Append text to this element.
|
|
getId()
Gets the value of the "id" attribute of this element.
|
|
getName()
Gets the element name (tag name).
|
|
Gets the value of the "name" attribute of this element.
|
|
hide()
Hides this element (display:none).
|
|
setAttribute(name, value)
Sets the value of an element attribute.
|
|
setAttributes(attributesPairs)
Sets the value of several element attributes.
|
|
setHtml(html)
Sets the inner HTML of this element.
|
|
setStyle(name, value)
Sets the value of an element style.
|
|
show()
Shows this element (display it).
|
- Methods borrowed from class CKEDITOR.dom.node:
- appendTo, insertAfter, insertBefore
Class Detail
CKEDITOR.dom.element(element)
Since:
3.0
Represents a DOM element.
// Create a new <span> element. var element = new CKEDITOR.dom.element( 'span' );
// Create an element based on a native DOM element. var element = new CKEDITOR.dom.element( document.getElementById( 'myId' ) );
- Parameters:
- {Object|String} element
- A native DOM element or the element name for new elements.
Field Detail
{Object}
$
Since:
3.0
The native DOM element represented by this class instance.
var element = new CKEDITOR.dom.element( 'span' ); alert( element.$.nodeType ); // "1"
Method Detail
<static>
{CKEDITOR.dom.element}
CKEDITOR.dom.element.createFromHtml(html)
Since:
3.0
Creates an instance of the CKEDITOR.dom.element class based on the
HTML representation of an element.
var element = CKEDITOR.dom.element.createFromHtml( '<strong class="anyclass">My element</strong>' ); alert( element.getName() ); // "strong"
- Parameters:
- {String} html
- The element HTML. It should define only one element in the "root" level. The "root" element can have child nodes, but not siblings.
- Returns:
- {CKEDITOR.dom.element} The element instance.
<static>
{CKEDITOR.dom.element}
CKEDITOR.dom.element.getById(id)
Since:
3.0
Creates an instance of the CKEDITOR.dom.element class representing an
element with the specific id.
var element = CKEDITOR.dom.element.getById( 'myElement' ); alert( element.getId() ); // "myElement"
- Parameters:
- {String} id
- The element id.
- Returns:
- {CKEDITOR.dom.element} The element instance, or null if not found.
<static>
{CKEDITOR.dom.element}
CKEDITOR.dom.element.getHead()
Since:
3.0
Creates an instance of the CKEDITOR.dom.element class representing the
<head> element.
var element = CKEDITOR.dom.element.getHead(); alert( element.getName() ); // "head"
- Returns:
- {CKEDITOR.dom.element} The element instance.
{CKEDITOR.dom.node}
append(node)
Since:
3.0
Append a node as a child of this element.
var p = new CKEDITOR.dom.element( 'p' ); var strong = new CKEDITOR.dom.element( 'strong' ); p.append( strong ); var em = p.append( 'em' ); // result: "<p><strong></strong><em></em></p>"
- Parameters:
- {CKEDITOR.dom.node|String} node
- The node or element name to be appended.
- Returns:
- {CKEDITOR.dom.node} The appended node.
{CKEDITOR.dom.node}
appendText(text)
Since:
3.0
Append text to this element.
var p = new CKEDITOR.dom.element( 'p' ); p.appendText( 'This is' ); p.appendText( ' some text' ); // result: "<p>This is some text</p>"
- Parameters:
- {String} text
- The text to be appended.
- Returns:
- {CKEDITOR.dom.node} The appended node.
{String}
getId()
Since:
3.0
Gets the value of the "id" attribute of this element.
var element = CKEDITOR.dom.element.createFromHtml( '<p id="myId"></p>' ); alert( element.getId() ); // "myId"
- Returns:
- {String} The element id, or null if not available.
{String}
getName()
Since:
3.0
Gets the element name (tag name). The returned name is guaranteed to
be always full lowercased.
var element = new CKEDITOR.dom.element( 'span' ); alert( element.getName() ); // "span"
- Returns:
- {String} The element name.
{String}
getNameAtt()
Since:
3.0
Gets the value of the "name" attribute of this element.
var element = CKEDITOR.dom.element.createFromHtml( '<input name="myName"></input>' ); alert( element.getNameAtt() ); // "myName"
- Returns:
- {String} The element name, or null if not available.
hide()
Since:
3.0
Hides this element (display:none).
var element = CKEDITOR.dom.element.getById( 'myElement' ); element.hide();
setAttribute(name, value)
Since:
3.0
Sets the value of an element attribute.
var element = CKEDITOR.dom.element.getById( 'myElement' ); element.setAttribute( 'class', 'myClass' ); element.setAttribute( 'title', 'This is an example' );
- Parameters:
- {String} name
- The name of the attribute.
- {String} value
- The value to be set to the attribute.
setAttributes(attributesPairs)
Since:
3.0
Sets the value of several element attributes.
var element = CKEDITOR.dom.element.getById( 'myElement' ); element.setAttributes({ 'class' : 'myClass', 'title' : 'This is an example' });
- Parameters:
- {Object} attributesPairs
- An object containing the names and values of the attributes.
{String}
setHtml(html)
Since:
3.0
Sets the inner HTML of this element.
var p = new CKEDITOR.dom.element( 'p' ); p.setHtml( '<b>Inner</b> HTML' ); // result: "<p><b>Inner</b> HTML</p>"
- Parameters:
- {String} html
- The HTML to be set for this element.
- Returns:
- {String} The inserted HTML.
setStyle(name, value)
Since:
3.0
Sets the value of an element style.
var element = CKEDITOR.dom.element.getById( 'myElement' ); element.setStyle( 'backgroundColor', '#ff0000' ); element.setStyle( 'marginTop', '10px' );
- Parameters:
- {String} name
- The name of the style. The the object DOM naming notation must be used.
- {String} value
- The value to be set to the style.
show()
Since:
3.0
Shows this element (display it).
var element = CKEDITOR.dom.element.getById( 'myElement' ); element.show();