JavaScript चेतावनी() फ़ंक्शन का उपयोग उपयोगकर्ता को पॉपअप संदेश प्रदर्शित करने के लिए किया जाता है।
जावास्क्रिप्ट अलर्ट () फ़ंक्शन के लिए कोड निम्नलिखित है -
उदाहरण
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
body {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
</style>
</head>
<body>
<h1>Javascript text alert</h1>
<button class="Btn">CLICK HERE</button>
<h3>Click on the above button to trigger the alert popup</h3>
<script>
let BtnEle = document.querySelector(".Btn");
BtnEle.addEventListener("click", () => {
alert("You pressed the button");
});
</script>
</body>
</html> आउटपुट
उपरोक्त कोड निम्न आउटपुट उत्पन्न करेगा -

'यहां क्लिक करें' बटन पर क्लिक करने पर -
