popup javascript code example

Example 1: javascript pop

var cars = ['mazda', 'honda', 'tesla'];
var telsa=cars.pop(); //cars is now just mazda,honda

Example 2: popup JavaScript code

document.getElementById("open-popup-btn").addEventListener("click",function(){
  document.getElementsByClassName("popup")[0].classList.add("active");
});
 
document.getElementById("dismiss-popup-btn").addEventListener("click",function(){
  document.getElementsByClassName("popup")[0].classList.remove("active");
});

Example 3: js alerts

3 types of JS Alerts

            - Information : You can only accept.
            - Confirmation: You can accept or decline.
            - Prompt    : You can accept, decline, and/or sendKeys.

Tags: