HTML DOM console.groupCollapsed() Method
Example
Create a collapsed group of messages in the console:
console.log("Hello world!");
console.groupCollapsed();
console.log("Hello again,
this time inside a collapsed group!");
Try it Yourself »
Definition and Usage
The console.groupCollapsed() method indicates the start of a collapsed message group.
Click the expand button to open the message group.
All messages will from now on be written inside this group.
Tip: Use the console.groupEnd() method to end the group.
Tip: Use the console.group() method for not-collapsed message groups.
Browser Support
The numbers in the table specify the first browser version that fully supports the method.
Method | |||||
---|---|---|---|---|---|
console.groupCollapsed() | 6 | 11.0 | 9.0 | 5.1 | Yes |
Syntax
console.group(label)
Parameter Values
Parameter | Type | Description |
---|---|---|
label | String | Optional. A label for the group |
More Examples
Example
End a group by using the console.groupEnd() method:
console.log("Hello world!");
console.groupCollapsed();
console.log("Hello again,
this time inside a collapsed group!");
console.groupEnd();
console.log("and we
are back.");
Try it Yourself »
Example
Specifying a label for the collapsed group:
console.log("Hello world!");
console.groupCollapsed("myLabel");
console.log("Hello again,
this time inside a collapsed group, with a label!");
Try it Yourself »