Build a Custom Popup Modal box | HTML, CSS & JQuery.

Hello Friends, Today in this post, we’ll learn How To Build a Custom Popup Modal box using HTML, CSS & JQuery. Recently I have shared a post, Responsive Full-Screen Image Slider | Hero Slider. but our today’s topic is Build a Custom Popup Modal box using HTML, CSS & JQuery.


A modal box is a popup window that forces the users to interact with it before returning to the site. Modal boxes are useful for warnings, informational boxes, and much more. You can create a modal box with jQuery. If you are familiar with jQuery, You can create it also with a bootstrap modal box.


In this article, you’ll learn how to build JQuery popup modals (popup windows) without using a framework like Bootstrap, or a third-party library. We’ll build the whole thing from pure css, giving us complete control over how it works and look.


The basic dialog window is an overlay positioned within the viewport and is protected from page content (like select elements) shining through with an iframe. It has a title bar and a content area and can be moved, resized, and closed with the ‘x’ icon by default.


jQuery is an open-source software permissive under an MIT license. jQuery is not a product of Pair Networks, Inc., and Pair Networks provides no warranty for jQuery. Please note that there are many levels of javascript libraries available.


Please consult with your IT professional for advice and guidance on an appropriate library. This specific product may or may not meet your needs. Pair Networks, Inc. is providing support for this tutorial for your convenience and is not responsible for jQuery’s performance.


Please read carefully the terms and scope of services for any online service or product you are considering purchasing or using. In order to create a modal pop-up you first all to establish the HTML structure.

Play Video

You have to create classes for the pop-up overlay and pop-up content so that you may edit them separately from the rest of the document. This example creates the “popup-overlay” and “popup-content” classes to enable CSS to style it specifically.


Take notice of the button elements in the below example. We added buttons that we want to trigger the pop-up. One button has been given the open cookies and another one for the open logged these will be used later to open and close the popup.


Now, we don’t want the popup to be hidden forever, so we need to make a special use case in the CSS for when the popup should be shown. We’re going to use jQuery to help determine when the popup should be visible.


jQuery has the ability to add and remove classes based on actions (like click). So, if we program jQuery to add a class called “active” when the “open” button is clicked, we can use the “active” class in CSS to show the popup.


Append the “active” class to the pop-up classes and create a new styling for when the pop-up is visible. Now it’s time to add the jQuery. Be sure to set up your HTML document for jQuery before adding any jQuery code.


If you are unsure how to do so, see our Getting Your HTML Ready for jQuery article. So when the “Open” and “Close” HTML buttons are clicked, jQuery needs to add or remove the “active” class.


When this happens, the “active” class is appended to the pop-up classes, thus changing the pop-up’s visibility to “visible.” In other words, the pop-up will appear. This second statement removes the “active” class when the “Close” button is clicked.


When this happens, the “active” class is removed from the pop-up classes, causing them to revert to their previous styling that has the visibility set to hidden. Add both statements of jQuery to your document. If all this is completed correctly, you will have a rudimentary modal pop-up box.


For any doubts and queries, feel free to leave comments below. Remember to subscribe to our channel. Do share the tutorial if you think it’s worth it.







27 thoughts on “Build a Custom Popup Modal box | HTML, CSS & JQuery.

  1. Your mode of describijg all in this pieece of writingg is in fact
    pleasant, all be capable of simply be aware of it, Thanks a lot.

    Here is my homepage greek voice over (Eliza)

  2. I have found very interesting your article.It’s pretty worth enough for me.
    In my view, if all website owners and bloggers made
    gookd contenbt as youu did, the web will be a lot more useful than ever

  3. Greetings! Verry helpful advice in this particular article!
    It’s the little changes thast make tthe most important changes.
    Many thanks for sharing!

  4. I enjoy what you guys aree usually up too. This type off clever work andd reporting!

    Keep up thhe very good works guys I’ve added you guys to my own video.

  5. I got this site from my pal who shared with me concerning this
    website and now tgis time I am browsing this website and reading very inmformative articles or reviews at this place.

  6. Hello There. I found your blog using google. This is an extremely well written article.
    I’ll make sure to booimark it and return to read more of your usefl information.Thanks for the
    post. I’ll certainly return.

  7. Excellent post. I was checking continuously this blog and I am impressed!
    Extremely useful information. I care for such information a lot.
    I was looking for this certain information for a very long time.Thank you and good luck.

  8. Really interesting information, I am sure this post has touched all internet users, its really really pleasant piece of writing on building up new website.

  9. I think this is one of the most important pieces of information for
    me. And i am glad to read your article. Butt wanna remark on few general things, The web site style is perfect, the articles is really great!

  10. I think this is one of the most important pieces of information for me.
    And I am glad to read your article. Butt wanna remark on few general things, The web site style is
    perfect, the articles is really great!

  11. Hey! This is my first comment hdre so I just wanted to
    give a quick shout out and say I truly enjoy reading through
    your articles. Appreciate it!

  12. Simply desire to say your article is as astounding. The clearness in your post is simply nice and i can assume you’re an expert on this subject.
    Well with your permission let me to grab your RSS feed
    to keep updated with forthcoming post. Thanks a million and please continue the rewarding work.

  13. What’s up to every body, it’s my first visit of this web site; this weblog includes amazing and in fact excellent

  14. Genuinely no matter if someone doesn’t know after that its up to other
    visitors that they will assist, so here it happens.

  15. Howdy! I simply want to give a huge thumbs up for the great info you could have here on this post. I can be coming again to your weblog for more soon.

Leave a Reply

Your email address will not be published. Required fields are marked *

Introducing Official ApeStaking Protocol for ApeCoin.

New Blur NFT Marketplace Courting Professional.