alert function

The function alert shows a modal box with a given message. The site user will not be able to continue working until he/she clicks on the OK button. Only text will be displayed, tags in the modal box will be ignored.

Syntax

javascriptalert(message);

Example

Let's make it so that when the button is clicked, a modal box appears with a message:

html<button id="button">click me</button>
javascriptlet button = document.querySelector('#button');

button.addEventListener('click', function(event) {
  alert('abcde');
});

Результат:

See also

  • the confirm function
    that brings up a confirmation dialog box
  • the prompt function
    that brings up a dialog box with a question