HTML DOM console error()
The console.error()function in HTML is used to show an error message on the console. It's mainly used for testing. You provide the error message as input to the console.error() function.
Syntax:
console.error( message )
Parameters: This approach takes in a required input called "message," which is used to store the error message.
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
color: green;
}
</style>
<title>Page Title</title>
</head>
<body style="text-align:center;">
<h1> Propertutorials </h1>
<h2> DOM console.error() Method </h2>
<p> To view the message in the console press the F12 key on your keyboard. </p>
<p> To check for errors, double click the button below: </p>
<button ondblclick="error_console()"> Check Errors </button>
<script>
function error_console() {
console.error("A mistake has been encountered.");
}
</script>
</body>
</html>