(
)
(
)
NodeList
ancestors
(
selector
)
Returns the current ancestors of the node element. If a selector is specified, the ancestors are filtered to match the selector.
Example:
A.one('#nodeId').ancestors('div');
selector
<String>
A selector to filter the ancestor elements against.
String
appendTo
(
selector
)
Insert the node instance to the end of the selector
element.
var node = A.one('#nodeId');
// using another Node instance
var body = A.one('body');
node.appendTo(body);
// using a CSS selector
node.appendTo('#container');
selector
<Node | String>
A selector, element, HTML string, Node
String
attr
(
name
,
value
)
Get or Set the value of an attribute for the first element in the
set of matched elements. If only the name
is passed it
works as a getter.
var node = A.one('#nodeId');
node.attr('title', 'Setting a new title attribute');
// Alert the value of the title attribute: 'Setting a new title attribute'
alert( node.attr('title') );
name
<String>
The name of the attribute
value
<String>
The value of the attribute to be set. Optional.
void
center
(
centerWith
)
Centralize the current Node instance with the passed
centerWith
Node, if not specified, the body will be
used.
var node = A.one('#nodeId');
// Center the node
with the #container
.
node.center('#container');
centerWith
<Node | String>
Node to center with
Node
clone
(
)
var node = A.one('#nodeId');
node.clone().appendTo('body');
void
empty
(
)
This method removes not only child (and other descendant) elements, but also any text within the set of matched elements. This is because, according to the DOM specification, any string of text within an element is considered a child node of that element.
Example:var node = A.one('#nodeId');
node.empty();
HTMLNode
getDOM
(
)
HTMLNode
String
guid
(
prefix
)
prefix
<string>
optional guid prefix
String
void
hide
(
cssClass
)
Hide the node adding a css class on it. If cssClass
is not
passed as argument, the className 'aui-helper-hidden' will be used by
default.
style.display
property.
cssClass
<string>
Class name to hide the element. Optional.
Node
hover
(
overFn
,
outFn
)
overFn
<string>
outFn
<string>
Node
void
html
(
value
)
Get or Set the HTML contents of the node. If the value
is passed it's set the content of the element, otherwise it works as a
getter for the current content.
var node = A.one('#nodeId');
node.html('Setting new HTML');
// Alert the value of the current content
alert( node.html() );
value
<string>
A string of html to set as the content of the node instance.
string
outerHTML
(
)
string
void
placeAfter
(
newNode
)
Inserts a newNode
after the node instance (i.e., as the next
sibling). If the reference node has no parent, then does nothing.
var titleNode = A.one('#titleNode');
var descriptionNode = A.one('#descriptionNode');
// the description is usually shown after the title
titleNode.placeAfter(descriptionNode);
newNode
<Node>
Node to insert.
void
placeBefore
(
newNode
)
Inserts a newNode
before the node instance (i.e., as the previous
sibling). If the reference node has no parent, then does nothing.
var descriptionNode = A.one('#descriptionNode');
var titleNode = A.one('#titleNode');
// the title is usually shown before the description
descriptionNode.placeBefore(titleNode);
newNode
<Node>
Node to insert.
void
prependTo
(
selector
)
Inserts the node instance to the begining of the selector
node (i.e., insert before the firstChild
of the
selector
).
var node = A.one('#nodeId');
node.prependTo('body');
selector
<Node | String>
A selector, element, HTML string, Node
void
radioClass
(
cssClass
)
cssClass
<String>
void
resetId
(
prefix
)
prefix
<String>
Optional prefix for the guid.
void
selectable
(
)
void
selectText
(
start
,
end
)
start
<Number>
The index to start the selection range from
end
<Number>
The index to end the selection range at
void
show
(
cssClass
)
Show the node removing a css class used to hide it. Use the same
className added using the hide
method. If cssClass
is not passed as argument, the
className 'aui-helper-hidden' will be used by default.
style.display
property.
cssClass
<string>
Class name to hide the element. Optional.
void
swallowEvent
(
eventName
,
preventDefault
)
Stops the specified event(s) from bubbling and optionally prevents the default action.
Example:var anchor = A.one('a#anchorId');
anchor.swallowEvent('click');
eventName
<String/Array>
an event or array of events to stop from bubbling
preventDefault
<Boolean>
(optional) true to prevent the default action too
void
text
(
text
)
Get or Set the combined text contents of the node instance,
including it's descendants. If the text
is passed it's set the content of the element, otherwise it works as a
getter for the current content.
var node = A.one('#nodeId');
node.text('Setting new text content');
// Alert the value of the current content
alert( node.text() );
text
<String>
A string of text to set as the content of the node instance.
void
toggle
(
cssClass
)
Displays or hide the node instance.
style.display
property.
cssClass
<String>
Class name to hide or show the element. Optional.
void
unselectable
(
)
void
val
(
value
)
Get or Set the value attribute of the node instance. If the
value
is passed it's set the value of the element,
otherwise it works as a getter for the current value.
var input = A.one('#inputId');
input.val('Setting new input value');
// Alert the value of the input
alert( input.val() );
value
<string>
Value to be set. Optional.