Browser support:
Allows inserting remarks into the source code.
Syntax:
Methods that return the object:
The base interface, through which you can add new functionalities to the
CommentNode object, is the
Comment interface.
If you want to see the HTML objects by categories, please visit this
page.
| HTML page for this element: !-- |
Possible members:
|
Properties |
|
Methods |
|
Style properties |
|
|
| baseURI |
|
Returns the base URL for the object.
|
| behaviorUrns |
|
Represents a collection of the Uniform Resource Names for all behaviors attached to an element.
|
| canHaveChildren |
|
Retrieves a Boolean value that indicates whether the element can contain child elements.
|
| canHaveHTML |
|
Retrieves a Boolean value that indicates whether the element can contain HTML formatted text.
|
| currentStyle |
|
Represents the computed style settings for an element.
|
| data |
|
Sets or returns the text content of a CommentNode, TextNode or comment element.
|
| id |
|
Sets or retrieves a unique identifier for the object.
|
| innerHTML |
|
Sets or retrieves the inner HTML content (the source code between the opening and closing tags) of an element.
|
| isContentEditable |
|
Returns a Boolean value that indicates whether the contents of the object are editable by the user.
|
| isDisabled |
|
Returns a Boolean value that indicates whether the object is disabled.
|
| isMultiLine |
|
Returns a Boolean value that indicates whether the contents of an element can be multiline or not.
|
| isTextEdit |
|
Returns a Boolean value that indicates whether the createTextRange method can be used for the element.
|
| length |
|
Returns the number of characters within a TextNode, CommentNode or comment object.
|
| nextSibling |
|
Returns a reference to the next child of the current element's parent.
|
| nodeName |
|
Returns the name of the current node.
|
| nodeType |
|
Returns an integer that indicates the type of the node.
|
| nodeTypeString |
|
Returns the type of the current node as a string.
|
| nodeValue |
|
Sets or returns the value of the current node.
|
| offsetParent |
|
Returns a reference to the closest ancestor element in the DOM hierarchy from which the position of the current element is calculated.
|
| outerHTML |
|
Sets or retrieves the outer HTML content (the source code including the opening and closing tags) of an element.
|
| outerText |
|
Sets or returns the text content of an element including the text content of its descendants.
|
| ownerDocument |
|
Returns the document object that contains the current node.
|
| parentElement |
|
Returns the parent element of the object in the DOM hierarchy.
|
| parentNode |
|
Returns the parent element of the current node in the DOM hierarchy.
|
| parentTextEdit |
|
Returns the closest ancestor element of the current element in the DOM hierarchy that can be used to create a TextRange object.
|
| previousSibling |
|
Returns a reference to the previous node of the current element's parent.
|
| readyState |
|
Returns a string value that represents the state of the object.
|
| runtimeStyle |
|
Represents the overridden style settings for an element.
|
| scopeName |
|
Retrieves the local name of the namespace declared for the current element.
|
| sourceIndex |
|
Returns the position of the current object in the all collection of the document.
|
| style |
|
Represents the inline style settings for an element or a CSS rule.
|
| tagName |
|
Returns the tag name of the current element.
|
| tagUrn |
|
Sets or retrieves the Uniform Resource Name (URN) of the namespace declared for the current element.
|
| text |
|
Sets or returns a string that corresponds the contents of the element.
|
| textContent |
|
Sets or returns the text content of an element including the text content of its descendants.
|
| uniqueID |
|
Returns the unique identifier generated by the browser for the object.
|
| addBehavior |
|
Attaches the specified behavior to the current element.
|
| addEventListener |
|
Registers an event handler function (event listener) for the specified event on the current object.
|
| appendData |
|
Appends the specified text content to the end of the current TextNode, CommentNode or comment element.
|
| applyElement |
|
Inserts the specified element as a child or parent of the current element.
|
| attachEvent |
|
Registers an event handler function (event listener) for the specified event on the current object.
|
| clearAttributes |
|
Clears all attributes from the current element, except the id, name, style, value and event attributes.
|
| cloneNode |
|
Returns an exact copy of the current node.
|
| compareDocumentPosition |
|
Compares the placement of the specified node with the current node in the DOM hierarchy.
|
| deleteData |
|
Removes the specified part of the text content of the current TextNode, CommentNode or comment element.
|
| detachEvent |
|
Removes the specified event handler from the current element that was registered earlier with the attachEvent method.
|
| dispatchEvent |
|
Dispatches the specified event to the current element.
|
| fireEvent |
|
Initializes an event object and dispatches it to the current element.
|
| getAdjacentText |
|
Returns the contents of the TextNode located at the specified position relative to the current element.
|
| getAttribute |
|
Returns the value of the attribute with the specified name from the current element.
|
| getAttributeNode |
|
Returns the attribute node with the specified name from the current element.
|
| hasAttributes |
|
Returns whether the current element has any attributes specified or not.
|
| hasChildNodes |
|
Returns whether the current node has any child nodes or not.
|
| insertAdjacentElement |
|
Inserts an element at the specified position relative to the current element.
|
| insertAdjacentHTML |
|
Inserts a HTML formatted text at the specified position relative to the current element.
|
| insertAdjacentText |
|
Creates a new TextNode from the specified text and inserts it at the specified position relative to the current element.
|
| insertData |
|
Inserts text content into the current TextNode, CommentNode or comment element at the specified position.
|
| isDefaultNamespace |
|
Returns whether the specified namespace URI is the default namespace in the scope of the current node.
|
| isEqualNode |
|
Returns whether the current node is equal to the specified one.
|
| isSameNode |
|
Returns whether the current node is the same node as the specified one.
|
| isSupported |
|
Returns whether the specified DOM module and version is supported by the current node.
|
| lookupNamespaceURI |
|
Retrieves the namespace URI associated with the specified namespace prefix in the scope of the current node.
|
| lookupPrefix |
|
Retrieves the namespace prefix associated with the specified namespace URI in the scope of the current node.
|
| mergeAttributes |
|
Copies all attributes and its values from the specified element to the current element.
|
| normalize |
|
Puts the subtree that belongs to the current node into a 'normalized' form.
|
| removeAttribute |
|
Removes the attribute with the specified name from the current element.
|
| removeAttributeNode |
|
Removes the specified attribute node from the current element.
|
| removeBehavior |
|
Removes the specified behavior from the current element.
|
| removeEventListener |
|
Removes the specified event handler from the current element that was registered earlier with the addEventListener method.
|
| removeNode |
|
Removes the current element with or without its children from the document tree.
|
| replaceData |
|
Replaces the specified part of the text content of the current TextNode, CommentNode or comment element with a new text.
|
| replaceNode |
|
Replaces the current element with the specified element.
|
| setAttribute |
|
Adds an attribute with the specified name and value to the current element.
|
| setAttributeNode |
|
Adds the specified attribute node to the current element.
|
| substringData |
|
Returns the part of the current element's text content from the specified position with the specified length.
|
| swapNode |
|
Interchanges the positions of the current element and the specified element in the document hierarchy.
|
| behavior |
|
Sets or retrieves the URL of a behavior file. |
| cssText |
|
Sets or retrieves the contents of a style declaration as a string. |
| hasLayout |
|
Returns a Boolean value that indicates whether the object has layout or not. |
| length |
|
Returns the number of properties that have been set in the current style object. |
|
Example HTML code 1:
This example illustrates the use of the comment tag:
|
|
<!-- This is a comment, the browser does not render it. -->
|
|
|
|
Did you find this example helpful?
yes
no
|
Example HTML code 2:
This example illustrates the use of the CommentNode object:
|
|
<head>
<script type="text/javascript">
function CreateComment () {
var commentContainer = document.getElementById ("commentContainer");
var comment = document.createComment ("Dynamically generated comment");
commentContainer.appendChild (comment);
alert (commentContainer.innerHTML);
}
</script>
</head>
<body>
<div id="commentContainer"></div>
<button onclick="CreateComment ();">Create a comment!</button>
</body>
|
|
|
|
Did you find this example helpful?
yes
no
|
Related pages:
External links:
|
Share:
|
Digg
|
Del.icio.us
|
Reddit
|
Facebook
|
Twitter
|
Diigo
|
|
User Contributed Comments