Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Example of using the addEventListener() method">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>addEventListener() example</title>
</head>
<body>
   <div class="popup" hidden>
      <h1>Heading</h1>
      <p>I'm a nice popup</p>
      <button class="close-button">Close popup</button>
   </div>
   <button class="open-button">Show popup</button>
</body>
</html>
 
const openButton = document.querySelector('.open-button');
const closeButton = document.querySelector('.close-button');
const popup = document.querySelector('.popup');
const hidePopupListener = {
   handleEvent: function() {
      popup.setAttribute('hidden', '');
   }
};
openButton.addEventListener('click', function() {
   popup.removeAttribute('hidden');
});
closeButton.addEventListener('click', hidePopupListener);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
AurelioDeRosapro
0viewers