DEV Community

manish srivastava
manish srivastava

Posted on

6 3

Pure Javascript Multiple Modals on a Page - Simplest

I wanted to use pure javascript for creating many modals on same page.And here is codepen :)

Top comments (7)

Collapse
 
shadowtime2000 profile image
shadowtime2000

Try modifying it and publish it as a library.

Collapse
 
manishfoodtechs profile image
manish srivastava • Edited

It is pure dead simple. Let it keep be as simple it is... no library.... only pure css and js. Anyway, thanks for good suggestion

Collapse
 
shane profile image
Shane McGowan

I respect this mentality more than I can express with words

Collapse
 
jackttcoms profile image
jackdev

hi how would i incorporate the escape key? thannks

Collapse
 
manishfoodtechs profile image
manish srivastava

var KEYCODE_ESC = 27;

$(document).keyup(function(e) {
if (e.keyCode == KEYCODE_ESC) $('.cancel').click();
});

Collapse
 
jackttcoms profile image
jackdev

ooo thanks. is it possible in vanilla javascript? thanks so much.

Thread Thread
 
realto619 profile image
Paul Leech

I converted it to vanilla JS here: codepen.io/Realto619/pen/ZEyWjKm

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️