HTML DOM console.groupCollapsed() Method

Definition and Usage

The console.groupCollapsed() method indicates the start of a collapsed message group.

Click the expand button to open the message group.

From now on, all messages will be written to this group.

Tip:Please use console.groupEnd() method End the group.

Tip:Use console.group() method.

Instance

Example 1

Create a group of collapsed messages in the console:

console.log("Hello world!");
console.groupCollapsed();
console.log("Hello again, this time inside a collapsed group!");

try it yourself

Example 2

Use the console.groupEnd() method to end a group:

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 3

Specify 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

syntax

console.groupCollapsed(label)

parameter value

parameter type description
label String Optional. Group tags.

Browser Support

The numbers in the table indicate the first browser version that fully supports this method.

Method Chrome IE Firefox Safari Opera
console.groupCollapsed() 6 11.0 9.0 5.1 Support