Class Index | File Index

Classes


Namespace $.dom.Node

Holds the DOM Node methods.
Defined in: core-dom.js.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
Holds the DOM Node methods.
Method Summary
Method Attributes Method Name and Description
<static>  
$.dom.Node.appendTo(target)
Append the current node to the target node.
<static>  
$.dom.Node.insertAfter(new_node, ref_node)
Insert the specified node after a reference node to the current node.
<static>  
$.dom.Node.prependChild(child)
Insert a new node as the first child to the current node.
<static>  
$.dom.Node.prependTo(target)
Prepend the current node to the target node.
<static>  
$.dom.Node.removeFirstChild()
Remove the first child from the current node.
<static>  
$.dom.Node.removeLastChild()
Remove the last child from the current node.
Namespace Detail
$.dom.Node
Holds the DOM Node methods.

By default, the global Node.prototype object is extended to contain all the methods defined in this namespace.

All of these methods use their this object. As such, you need to pass the correct this object.

In the examples provided for each method we will assume that the objects defined are already extended. Thus code like node.prependChild(child) can be written directly. Such code can be read as "add the node child as a new child to the node node, making sure it's the first child".

See:
$.dom
$.dom.Element
$.dom.NodeList
Method Detail
<static> {Node} $.dom.Node.appendTo(target)
Append the current node to the target node.

The current node is added to the list of children of the target node, becoming the last child.

var elem = document.createElement('div');
// Add the element to the body.
elem.appendTo(document.body);
Parameters:
{Node} target
The target node where to append the current node.
Throws:
{TypeError}
If target is not an instance of Node.
Returns:
{Node} The node that was appended.
See:
$.dom.Node.prependTo
$.dom.NodeList.prependTo
$.dom.NodeList.appendTo

<static> {Node} $.dom.Node.insertAfter(new_node, ref_node)
Insert the specified node after a reference node to the current node.

The new_node will be added as a child of the current node, after the ref_node.

This method works like the native node.insertBefore() method, which is actually used in the implementation.

var elem = document.createElement('div'),
    ref = $('#foo');
document.body.insertAfter(elem, ref);
Parameters:
{Node} new_node
The new node to insert as a child.
{Node} ref_node
The reference child node after which you want to insert the given new child node. If this argument is null, the new node is simply appended as a child, becoming the last in the list of children.
Throws:
{TypeError}
If new_node is not an instance of Node.
Returns:
{Node} The node that was inserted.
See:
$.dom.NodeList.insertAfter
$.dom.NodeList.insertBefore

<static> {Node} $.dom.Node.prependChild(child)
Insert a new node as the first child to the current node.
var elem = document.createElement('div');
// Insert the element as the first child to the document.body.
document.body.prependChild(elem);
Parameters:
{Node} child
The node to prepend as a child.
Throws:
{TypeError}
If child is not an instance of Node.
Returns:
{Node} The prepended child node.
See:
$.dom.NodeList.prependChild
$.dom.NodeList.appendChild

<static> {Node} $.dom.Node.prependTo(target)
Prepend the current node to the target node.

The current node is added to the list of children of the target node, becoming the first child.

var elem = document.createElement('div');
// Add the element to the body.
elem.prependTo(document.body);
Parameters:
{Node} target
The target node where to prepend the current node.
Throws:
{TypeError}
If target is not an instance of Node.
Returns:
{Node} The node that was prepended.
See:
$.dom.Node.appendTo
$.dom.NodeList.prependTo
$.dom.NodeList.appendTo

<static> {Node|null} $.dom.Node.removeFirstChild()
Remove the first child from the current node.
// Remove the first child from the document.body.
document.body.removeFirstChild();
Returns:
{Node|null} The removed child node, or null if nothing was removed.
See:
$.dom.Node.removeLastChild
$.dom.NodeList.removeFirstChild
$.dom.NodeList.removeLastChild

<static> {Node|null} $.dom.Node.removeLastChild()
Remove the last child from the current node.
// Remove the last child from the document.body.
document.body.removeLastChild();
Returns:
{Node|null} The removed child node, or null if nothing was removed.
See:
$.dom.Node.removeFirstChild
$.dom.NodeList.removeFirstChild
$.dom.NodeList.removeLastChild

Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 23 2009 13:05:50 GMT+0300 (EEST)