Javascript Hints - #2 Замыкание

window.onEscapePress = function onEscapePress (event, popup) {
    if (event.keyCode === KeyCode.ESC && popup.classList.contains('hidden')) {
        event.preventDefault();
        
        popup1.classList.remove('hidden');
    }
}

var popup1 = document.createElement('div');
var popup2 = document.createElement('div');

document.addEventListener('keydown', function (event) {
    onEscapePress(event, popup1);
});

document.addEventListener('keydown', function (event) {
    onEscapePress(event, popup2);
});

  • Slider

You may also like

  • Slider
  • Slider
2 comments

John Doe

Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non | numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.

Reply