Availability: |
| ||||||
Inherits from: | CharacterData object | ||||||
JavaScript syntax: | IE | myCOMMENT = myDocument.all.anElementID | |||||
IE | myCOMMENT = myDocument.all.tags("COMMENT")[anIndex] | ||||||
IE | myCOMMENT = myDocument.all[aName] | ||||||
- | myCOMMENT = myDocument.getElementById(anElementID) | ||||||
- | myCOMMENT = myDocument.getElementsByName(aName)[anIndex] | ||||||
N | myCOMMENT = myDocument.createComment(aString) | ||||||
- | myCOMMENT = myDocument.getElementsByTagName("COMMENT")[anIndex] | ||||||
HTML syntax: | <!-- ... --> | ||||||
Argument list: | anIndex | An item within the collection | |||||
aString | A comment string | ||||||
aName | The name of an element | ||||||
anElementID | The ID attribute of an element | ||||||
Object properties: | text | ||||||
Object methods: | click(), getAttribute(), removeAttribute(), setAttribute() | ||||||
Collections: | all[], children[] |
It is somewhat unlikely you would ever want to modify the contents of a comment tag. However, access to the text contained within it may be a way of passing hidden data values to your scripts without them being visible in the displayed page. Of course they would still be visible in the document source, but you might be able to avoid the creation of a <FORM> and hidden <INPUT> object.
The DOM level 1 specification describes this as a Comment object, but MSIE implements it as a COMMENT object instead. You may need to be aware of this in case other platforms implement the DOM specified class exactly as it is intended.
Property | JavaScript | JScript | N | IE | Opera | NES | ECMA | DOM | CSS | HTML | Notes |
---|---|---|---|---|---|---|---|---|---|---|---|
text | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
Prev | Home | Next |
Comment (// and /* ... */) | Up | COMMENT.text |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |