
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM console.group() Method
The HTML DOM console.group() method is used to indicate the start of message group and all messages written after this method will be written inside the message group. This allows making one group for all messages or several groups using the label parameter.
Syntax
Following is the syntax for the console.group() method −
console.group([label])
Here, label is an optional parameter. It is of type string and acts as a label for the message group created.
Example
Let us look at an example for the HTML DOM console.group() method −
<!DOCTYPE html> <html> <body> <h1>console.group() Method</h1> <p>Press F12 key to view the message in the console view.</p> <button type="button" onclick="normMessage()">NORMAL</button> <button type="button" onclick="groupMessage()">GROUP</button> <script> function normMessage(){ console.log("Hello world!"); } function groupMessage(){ console.group(); console.log("This message will be inside a group!"); console.log("This message will also be inside a group!"); } </script> </body> </html>
Output
This will produce the following output −
On clicking the NORMAL button and looking at console −
On clicking the GROUP button and looking at console −
In the above example −
We have created two buttons NORMAL and GROUP that will execute the normMessage() and groupMessage() method upon being clicked by the user.
<button type="button" onclick="normMessage()">NORMAL</button> <button type="button" onclick="groupMessage()">GROUP</button>
The normMessage() method has the console.log() method that takes in a string or object supplied as a parameter and simply displays it to the console −
function normMessage(){ console.log("Hello world!"); }
The groupMessage() method has the console.group() method inside it that states all the messages written after this point will be displayed inside a message group:
function groupMessage(){ console.group(); console.log("This message will be inside a group!"); console.log("This message will also be inside a group!"); }
- Related Articles
- HTML DOM addEventListener() Method
- HTML DOM normalize( ) Method
- HTML DOM write() Method
- HTML DOM writeln() Method
- HTML DOM insertAdjacentElement( ) Method
- HTML DOM insertAdjacentHTML( ) Method
- HTML DOM insertAdjacentText( ) Method
- HTML DOM insertBefore( ) Method
- HTML DOM isDefaultNamespace( ) Method
- HTML DOM isEqualNode( ) Method
- HTML DOM isSameNode( ) Method
- HTML DOM item( ) Method
- HTML DOM appendChild() Method
- HTML DOM blur() Method
- HTML DOM click() method
