What are the different types of Alerts / Popups in JavaScript.

preview_player
Показать описание
What are the different types of Alerts / Popups in JavaScript.

Code:

Alert Box:
function myFunction() {
alert("I am an alert box!");
}

Confirmation Box:
function myFunction() {
var txt;
if (confirm("Press a button!")) {
txt = "You pressed OK!";
} else {
txt = "You pressed Cancel!";
}
}

prompt Box:
function myFunction() {
let text;
let person = prompt("Please enter your name:", "Azhar Jamal");
if (person == null || person == "") {
text = "User cancelled the prompt.";
} else {
text = "Hello " + person + "! How are you today?";
}
}

Line Breaks:
button onclick="alert('Hello\nHow are you?')" Click it /button

Next Steps :

---------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------
Must Watch Playlists

---------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------

#alerts
#popups
#javascript
Рекомендации по теме
join shbcf.ru