Comment: Comment() Konstruktor
        
        
          
                Baseline
                
                  Widely available
                
                
              
        
        
        
          
                
              
                
              
                
              
        
        
      
      This feature is well established and works across many devices and browser versions. It’s been available across browsers since Oktober 2017.
Der Comment() Konstruktor gibt ein neu erstelltes Comment-Objekt mit dem optional übergebenen String als Textinhalt zurück.
Syntax
js
new Comment()
new Comment(content)
Parameter
- contentOptional
- 
Ein String, der den Textinhalt des Kommentars darstellt. 
Rückgabewert
Ein neues Comment, das content enthält, oder ein leerer String, wenn kein Parameter angegeben wurde.
Beispiel
js
const comment = new Comment("Test");
Spezifikationen
| Specification | 
|---|
| DOM> # ref-for-dom-comment-comment①> | 
Browser-Kompatibilität
Loading…
Siehe auch
- Das DOM-Schnittstellenverzeichnis
- Document.createComment()ist eine veraltete Alternative zu diesem Konstruktor.