English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML DOM createComment() Method

HTML DOM Document Object

createComment()The method creates a comment node with specified text.

Syntax:

document.createComment(text)
var c = document.createComment("This is a comment");
document.body.appendChild(c);
Test See‹/›

Browser Compatibility

All browsers fully support the createComment() method:

Method
createComment()YesYesYesYesYes

Parameter Value

ParameterDescription
textA string containing the text to be added to the comment

Technical Details

Return Value:The Comment object representing the Comment node created
DOM Version:DOM Level1

HTML DOM Document Object