HTML DOM console.info() Method


The HTML DOM console.info() method is used to write an informational message to the console. This method is useful for debugging and testing purposes. Some browsers e.g: firefox, chrome display a small i icon in blue color for the statements printed using this method.

Syntax

Following is the syntax for the HTML DOM console.info() method −

console.info( message )

Here, the message is a required parameter and can be of type string or object. It is displayed in the console.

Example

Let us see an example for the HTML DOM console.info() method −

Live Demo

<!DOCTYPE html>
<html>
<body>
<h1>console.info() Method</h1>
<p>Press F12 key to view the message in the console view.</p>
<button onclick="printInfo()">INFO</button>
<script>
   function printInfo(){
      console.info("Information is printed");
      console.info("This is some other information ");
   }
</script>
</body>
</html>

Output

This will produce the following output −

On clicking the INFO button and looking at console view −

In the above example −

We have created a button INFO that will execute the function printInfo() when clicked by the user −

<button onclick="printInfo()">INFO</button>

The printInfo() method has console.info() method inside it that prints informational message to the console. As seen in the output there is an i icon beside the messages written using console.info() −

function printInfo(){
   console.info("Information is printed");
   console.info("This is some other information ");
}

Updated on: 20-Feb-2021

10 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements