🌐
W3Schools
w3schools.com › howto › howto_css_modals.asp
W3Schools.com
Fullscreen Video Modal Boxes Delete Modal Timeline Scroll Indicator Progress Bars Skill Bar Range Sliders Color Picker Email Field Tooltips Display Element Hover Popups Collapsible Calendar HTML Includes To Do List Loaders Badges Star Rating User Rating Overlay Effect Contact Chips Cards Flip ...
🌐
Bootstrap
getbootstrap.com › docs › 4.0 › components › modal
Modal · Bootstrap
Use Bootstrap’s JavaScript modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content.
Discussions

Creating a modal using CSS, using buttons to trigger the modal popup
Swapnil Srivastava is having issues with: Hi, I wanted open a modal popup using the CSS only, using the class of the button I want to trigger the modal pop up. I have t... More on teamtreehouse.com
🌐 teamtreehouse.com
4
April 12, 2016
4 Ways to Create a Modal Popup Box with Html, CSS and Vanilla JavaScript
This tutorial includes no mention of accessibility, and because it doesn't trap focus, can actually result in a bad user experience. I recommend looking over the W3 modal tutorial and incorporating some of the points about focus trapping and accessibility into this one https://www.w3.org/TR/wai-aria-practices-1.1/examples/dialog-modal/dialog.html More on reddit.com
🌐 r/learnprogramming
14
351
January 30, 2021
html - how to write a modal popup in javascript - Stack Overflow
I have a table that displays data along side with a button, I want the button to display a modal popup when it's click. I have written a javascript code to do that but it's not working. I don't hav... More on stackoverflow.com
🌐 stackoverflow.com
html - How to create a modal popup using javascript and CSS - Stack Overflow
Actually, two questions: How can I create a modal popup with background color of gray? Also I need to create for a cover background color only to table itself. Not to overall page. How do I do this More on stackoverflow.com
🌐 stackoverflow.com
🌐
Medium
medium.com › @rjgorz › creating-a-modal-popup-html-css-vanilla-js-ec759500d479
Creating A Modal “Popup” || HTML/CSS/Vanilla JS | by Robert Gorz | Medium
January 26, 2023 - This bit of code styled the box to match the aesthetic of the rest of the page, positioned it at the very center of the top of the page, and hid it from view temporarily. To render the content and make the modal appear in the foreground, I utilized ...
🌐
CodingNepal
codingnepalweb.com › home › card design › create popup modal box in html css & javascript
Create Popup Modal Box in HTML CSS & JavaScript
May 13, 2023 - As you have seen in the video of this project [ Popup Modal Box]. At first, there was a button on the screen with the name “Open Modal”, When I clicked on that button the button disappeared and a modal box, as well as a little dark color overly behind the modal box, appeared. As you the modal box can be closed by clicking on the close button or just by clicking on the outside of the modal box. To make the UI design of this project [ Popup Modal Box], I just used HTML and CSS, and to open and close it, I used some JavaScript code.
🌐
W3Schools
w3schools.com › bootstrap › bootstrap_modal.asp
Bootstrap Modals
The .modal-body class is used to define the style for the body of the modal. Add any HTML markup here; paragraphs, images, videos, etc.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › Reference › Selectors › :modal
:modal - CSS | MDN
December 16, 2025 - <!-- Basic modal dialog containing a form --> <dialog id="favDialog"> <form method="dialog"> <p> <label >Favorite animal: <select> <option value="default">Choose…</option> <option>Brine shrimp</option> <option>Red panda</option> <option>Spider monkey</option> </select> </label> </p> <div> <button value="cancel">Cancel</button> <button id="confirmBtn" value="default">Confirm</button> </div> </form> </dialog> <p> <button id="updateDetails">Update details</button> </p> <output></output>
🌐
Adobe Support Community
community.adobe.com › questions-621 › html-css-modal-popup-problems-642756
HTML CSS Modal Popup Problems | Community
August 2, 2021 - <!DOCTYPE html> <html> <head> <!-- --------------- IF I LINK TO EXTERNAL STYLESHEET BUTTON DISAPPEARS --> <!-- <link href="css/global.css" rel="stylesheet" type="text/css" /> --> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style> body { font-family: Arial, Helvetica, sans-serif; } /* The Modal (background) */ .modal { display: none; /* Hidden by default */ position: fixed; /* Stay in place */ z-index: 1; /* Sit on top */ padding-top: 100px; /* Location of the box */ left: 0; top: 0; width: 100%; /* Full width */ height: 100%; /* Full height */ overflow: auto; /* Ena
Find elsewhere
🌐
Team Treehouse
teamtreehouse.com › community › creating-a-modal-using-css-using-buttons-to-trigger-the-modal-popup
Creating a modal using CSS, using buttons to trigger the modal popup (Example) | Treehouse Community
April 12, 2016 - I wanted to you use the class in order to trigger the opening of the modal, without changing the code. the code is mentioned below . html <button type="submit" class="btn-action">Add to bag </button>
🌐
Medium
matemarschalko.medium.com › lets-build-a-html-and-css-only-popup-modal-5bf26ec62c7a
Lets build a HTML- and CSS-only Popup Modal | by Mate Marschalko | Medium
December 6, 2024 - The principle behind both the modal window and the dismissible banner is very simple: we only have two hidden checkboxes and three labels to control them. Regardless of the simplicity, this idea gives us so many possibilities! Especially if we remember that the label doesn’t have to be a simple piece of text or a simple button. It can be changed freely to a complex component as it works as a container for other HTML elements.
🌐
Envato Tuts+
webdesign.tutsplus.com › home › web design › html/css › animation
How to Build a JavaScript Popup Modal From Scratch | Envato Tuts+
November 3, 2023 - In this tutorial we’ll learn how to build flexible popup modals (windows) with HTML, CSS, and JavaScript–without using a framework like Bootstrap!
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-create-a-modal-box-using-html-css-and-javascript
How to Create a Modal Box using HTML CSS and JavaScript? - GeeksforGeeks
Add event listeners to close the modal when the close button or overlay is clicked. Example: In this example, we will use the above approach. ... <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="styles.css" /> <title>Page Title</title> </head> <body> <div class="open-modal-btn-wrapper"> <button class="open-modal-btn"> Open Modal </button> </div> <div class="modal-overlay hide"> <div class="modal-wrapper"> <div class="close-btn-wrapper"> <button class="close-modal-btn"> Close </button> </div> <h1>GeeksforGeeks</h1> <div class="modal-content"> Greetings from GeeksforGeeks </div> </div> </div> <script src="script.js"></script> </body> </html>
Published   December 5, 2025
Top answer
1 of 1
1

Your example code isn't just regular JavaScript, it looks like jQuery and it looks like you are trying to use a jQuery modal plugin. If that's the route you want to go, you need to do some setup that depends on your specific situation. Your code and setup is so complex and specific that I recommend learning more fundamentals before proceeding OR rebuilding this specific part of your application.

Also; you are using IDs to target your elements, but you have multiple elements with the same ID, which should never happen.

Below I have a tiny demo of a custom "modal" type thing using just HTML, CSS and vanilla (meaning plain) JS without jQuery

function toggleModal(e) {
    e.stopPropagation()
    backdrop.classList.toggle("active")
}
const backdrop = document.querySelector(".backdrop")
const button = document.querySelector("button")
backdrop.addEventListener("click", toggleModal)
button.addEventListener("click", toggleModal)
.backdrop {
  display: none;
  position: fixed;
  width:100vw;
  height:100vh;
  cursor:pointer;
  background:#00000088;
  top: 0;
}
.backdrop.active {
  display: flex;
  justify-content: center;
  align-items: center;
}
.modal {
  background: #ffffff;
  min-width:30vw;
  min-height: 30vh;
  cursor:initial;
}
<button>OpenModal</button>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam vel consectetur ex, id pharetra ex. In ligula leo, euismod eu gravida sed, facilisis non dolor. In hac habitasse platea dictumst. Aenean sapien dolor, aliquam quis odio a, feugiat rutrum turpis. Duis eu eleifend urna. Fusce quis quam hendrerit, varius nibh sed, tempor erat. Fusce iaculis finibus lacus in fringilla. Nullam tincidunt odio eu efficitur lacinia. Vivamus id tempus mauris, in laoreet magna. Integer ornare, odio quis ullamcorper ultrices, purus nisl elementum erat, id semper eros nunc et orci. Morbi neque purus, fringilla ut rutrum quis, commodo vel arcu.</p>
<p>Integer sit amet volutpat ante. Donec sed sem non nisi hendrerit volutpat ac vel ante. Suspendisse nec nulla interdum, aliquam mauris non, porta elit. Suspendisse potenti. Proin placerat tincidunt malesuada. Nullam accumsan mi finibus orci pretium pharetra. Nunc at efficitur leo, sit amet ultrices arcu. Aenean non nibh congue, efficitur justo et, posuere ante. Phasellus maximus augue at pulvinar pulvinar. Integer tempor, orci eu pellentesque finibus, enim tortor hendrerit dui, quis semper lorem dolor ac nulla. Mauris congue venenatis blandit. Pellentesque a mi in odio venenatis iaculis vel non elit.</p>

<div class="backdrop">
  <div class="modal">
    I am a modal
  </div>
</div>

🌐
React Native
reactnative.dev › docs › modal
Modal · React Native
3 weeks ago - The Modal component is a basic way to present content above an enclosing view.
🌐
Illustrate Digital
illustrate.digital › home › blog › what are modals, popups and lightboxes?
What are modals, popups and lightboxes? : Illustrate Digital
April 9, 2024 - This would mean that the modal prevents interaction with the page while the dialogue provides a means to dismiss the dialogue and modal once interacted with. A lightbox is actually a specific Javascript library which has come to be used as a generic term for any popup that darkens the website and displays a dialog containing an image or other content.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › HTML › Reference › Elements › dialog
<dialog>: The Dialog element - HTML | MDN
3 weeks ago - The command attribute sets the particular command that is to be sent when the <button> element is clicked, while commandfor sets the id of the target dialog. The commands that can be sent for dialogs are "show-modal", "close", and "request-close". The HTML below demonstrates how to apply the attributes to a <button> element so it can be pressed to open a modal <dialog> with an id of "my-dialog".
🌐
Cyberdesign
cyberdesign.ro › home › web insights › creating a modal popup with javascript, css, and html: a step-by-step guide
Mastering Modal Popups: A Comprehensive Guide with JavaScript, CSS, and HTML Examples
December 27, 2023 - Now, you have a basic modal popup that opens when the button is clicked and closes when the close button or the outside area is clicked. Customize the modal content and styles according to your project’s requirements. Integrate the modal into your web pages by copying the HTML structure and linking the CSS and JavaScript files.
🌐
W3Schools
w3schools.com › w3css › w3css_modal.asp
W3.CSS Modal
Web Intro Web HTML Web CSS Web ... W3.CSS Downloads · ❮ Previous Next ❯ · A modal is a dialog box/popup window that is displayed on top of the current page: Open Modal ·...
🌐
Jason Watmore's Blog
jasonwatmore.com › post › 2023 › 01 › 04 › vanilla-js-css-modal-popup-dialog-tutorial-with-example
Vanilla JS + CSS - Modal Popup (Dialog) Tutorial with Example | Jason Watmore's Blog
January 4, 2023 - Modal #2 - a tall popup to demonstrate that the modal is scrollable while keeping the page below locked in position. ... The index.html file contains three main div elements, one for the page heading and buttons to open the modals (modal-1 and modal-2), and two divs for the modals themselves.