๐ŸŒ
CodePen
codepen.io โ€บ brandonb927 โ€บ pen โ€บ ZEMGbN
Simple jQuery Modal Popup
// Quick & dirty toggle to demonstrate modal toggle behavior $('.modal-toggle').on('click', function(e) { e.preventDefault(); $('.modal').toggleClass('is-visible'); });
๐ŸŒ
CodePen
codepen.io โ€บ lovol2 โ€บ pen โ€บ yxMJxG
Simple Jquery Popup/Modal
$('.open-popup').on('click', function() { openpopupnow(); }); $('.popup-close').on('click', function() { $('.overlay').removeClass('shown'); }); $('.btn_yes').on('click', function() { $('.overlay').removeClass('shown'); }); $(document).on('keyup', ...
๐ŸŒ
CodePen
codepen.io โ€บ kelvinangulo โ€บ pen โ€บ ybzqze
Open modal with jQuery on('click'
$('#mainHeader').before($( '<div class="modalContainer">' + '<div class="modalContent">' + '<div class="heading">HELLO WORLD</div>' + '<div class="close_btn">&times;</div>' + '<div class="text1">Here is a simple modal.</div>' + '</div>' + '</div>' ).fadeIn()); $('.close_btn').on('click', function(){ $('.modalContainer').remove(); }) } $('.openModalButton').on('click', function(){ openModalFunction(); })
๐ŸŒ
CodePen
codepen.io โ€บ jeffleulier โ€บ pen โ€บ VOepLd
Jquery Modal
<!-- Remember to include jQuery :) --> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script> <!-- jQuery Modal --> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.css" /> <!-- By default link takes user to /login.html --> <a href="" data-modal="#login-modal">Login</a> <!-- Login modal embedded in page --> <div id="login-modal" class="modal"> ... </div> ... $(function() { $('a[data-modal]').on('click', function() { $($(this).data('modal')).modal({ fadeDuration: 250 }); return false; }); });
๐ŸŒ
CodePen
codepen.io โ€บ diesel1064 โ€บ pen โ€บ nNVXBd
Simple jQuery Modal
$(document).ready(function(){ $('.modal-link').click(function(){ $('.modal').show(); $('.modal-bg').show(); }); $('.modal .close').click(function(){ $('.modal').hide(); $('.modal-bg').hide(); }) })
๐ŸŒ
CodePen
codepen.io โ€บ kirtiparmar95 โ€บ pen โ€บ VwXpQmr
Custom Jquery Modal
(function($) { "use strict"; $(document).ready(function() { $('.modal-link').on('click', function() { $('body').addClass("modal-open"); }); $('.close-modal').on('click', function() { $('body').removeClass("modal-open"); }); }); }(jQuery));
๐ŸŒ
CodePen
codepen.io โ€บ ud-kazi โ€บ pen โ€บ BaNJzpY
How to open modal on page load using jquery
<!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> <title>Hello, world!</title> </head> <body> <h1 style="text-align: center;">Hello, world!</h1> <!-- Button trigger modal --> <!-- Modal --> <div class="modal fade" id="exampleModal" tabin
๐ŸŒ
CodePen
codepen.io โ€บ drmikeh โ€บ pen โ€บ ZOMEYJ
jQuery Dynamic Modal
<div class="bs-example"> <!-- Button HTML (to Trigger Modal) --> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal" data-num="0">Question 1</button> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal" data-num="1">Question 2</button> <!-- Modal HTML --> <div id="myModal" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">ร—</button> <h4 class="modal-title">Modal Window</h4> </div> <div class="modal-body"> </div> <div class="modal-footer"> <button type="button" class="btn btn-primary" class="close" data-dismiss="modal" onclick="submit()">Submit</button> </div> </div> </div> </div> <hr/> <h4 id="selected"></h4> </div>
๐ŸŒ
CodePen
codepen.io โ€บ kiyara โ€บ pen โ€บ maeGKp
modal popup on click
$(document).ready(function() { $(".open").click(function () { $(".modalDialog1").modal("show"); }); $(".thanks-btn1").on('click',function(){ $(".modalDialog1").css("display","none"); }); $(".close1").on('click',function(){ $(".modalDialog1").css("display","none"); }); $(".modal-backdrop1").click(function () { $(".modalDialog1").css("display","none"); }); });
Find elsewhere
๐ŸŒ
CodePen
codepen.io โ€บ kaiak โ€บ pen โ€บ yLyqxOY
simple popup jquery
$("button").click(function() { $(".popup").fadeIn(500); }); $(".close").click(function() { $(".popup").fadeOut(500); });
๐ŸŒ
CodePen
codepen.io โ€บ pairdocs โ€บ pen โ€บ JOpWPz
jQuery Pop-Up
//appends an "active" class to .popup and .popup-content when the "Open" button is clicked $(".open").on("click", function(){ $(".popup-overlay, .popup-content").addClass("active"); }); //removes the "active" class to .popup and .popup-content ...
๐ŸŒ
CodePen
codepen.io โ€บ ariwinokur โ€บ pen โ€บ vGzELM
Super Simple Modal Popups with jQuery and CSS3 Transitions
<div id="popup" class="modal-box"> ... href="#" class="js-modal-close">Close Button</a> </footer> </div> <a class="js-open-modal" href="#" data-modal-id="popup"> Click me ......
๐ŸŒ
Kreweofcarrollton
kreweofcarrollton.org โ€บ vmrf โ€บ open-modal-popup-using-jquery-on-button-click-codepen
open modal popup using jquery on button click codepen
Learn more <!--. So, if we program ... from the rest of the document. open modal popup using jquery on button click codepen June 15, 2021 const Modal = () => (....
๐ŸŒ
CodePen
codepen.io โ€บ D-B-M โ€บ pen โ€บ poojYLd
simple jquery popup
// jQuery extend functions for popup (function($) { $.fn.openPopup = function( settings ) { var elem = $(this); // Establish our default settings var settings = $.extend({ anim: 'fade' }, settings); elem.show(); elem.find('.popup-content').addClass(settings.anim+'In'); } $.fn.closePopup = function( settings ) { var elem = $(this); // Establish our default settings var settings = $.extend({ anim: 'fade' }, settings); elem.find('.popup-content').removeClass(settings.anim+'In').addClass(settings.anim+'Out'); setTimeout(function(){ elem.hide(); elem.find('.popup-content').removeClass(settings.anim+'Out') }, 500); } }(jQuery)); // Click functions for popup $('.open-popup').click(function(){ $('#'+$(this).data('id')).openPopup({ anim: (!$(this).attr('data-animation') || $(this).data('animation') == null) ?
Top answer
1 of 4
11

show openModal div on button1 click.

$('#button1').on('click', function() {
    $('#openModal').show();
});

No need of onclick="myFunction()" on button

2 of 4
3

Let's try...

Simple popup model created by using jquery, HTML, and CSS.

$(function() {
    // Open Popup
    $('[popup-open]').on('click', function() {
        var popup_name = $(this).attr('popup-open');
 $('[popup-name="' + popup_name + '"]').fadeIn(300);
    });
 
    // Close Popup
    $('[popup-close]').on('click', function() {
 var popup_name = $(this).attr('popup-close');
 $('[popup-name="' + popup_name + '"]').fadeOut(300);
    });
 
    // Close Popup When Click Outside
    $('.popup').on('click', function() {
 var popup_name = $(this).find('[popup-close]').attr('popup-close');
 $('[popup-name="' + popup_name + '"]').fadeOut(300);
    }).children().click(function() {
 return false;
    });
 
});
body {
    font-family:Arial, Helvetica, sans-serif;
}
 
p {
    font-size: 16px;
    line-height: 26px;
    letter-spacing: 0.5px;
    color: #484848;
}
 
/* Popup Open button */ 
.open-button{
    color:#FFF;
    background:#0066CC;
    padding:10px;
    text-decoration:none;
    border:1px solid #0157ad;
    border-radius:3px;
}
 
.open-button:hover{
    background:#01478e;
}
 
.popup {
    position:fixed;
    top:0px;
    left:0px;
    background:rgba(0,0,0,0.75);
    width:100%;
    height:100%;
    display:none;
}
 
/* Popup inner div */
.popup-content {
    width: 500px;
    margin: 0 auto;
    box-sizing: border-box;
    padding: 40px;
    margin-top: 20px;
    box-shadow: 0px 2px 6px rgba(0,0,0,1);
    border-radius: 3px;
    background: #fff;
    position: relative;
}
 
/* Popup close button */
.close-button {
    width: 25px;
    height: 25px;
    position: absolute;
    top: -10px;
    right: -10px;
    border-radius: 20px;
    background: rgba(0,0,0,0.8);
    font-size: 20px;
    text-align: center;
    color: #fff;
    text-decoration:none;
}
 
.close-button:hover {
    background: rgba(0,0,0,1);
}
 
@media screen and (max-width: 720px) {
.popup-content {
    width:90%;
    } 
}
<!DOCTYPE html>
<html>
<head>
 <title> Popup </title>
 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
</head> 

<body>
    <a class="open-button" popup-open="popup-1" href="javascript:void(0)"> Popup 
        Preview</a>
         
        <div class="popup" popup-name="popup-1">
            <div class="popup-content">
            <h2>Model </h2>
        <p>Model content will be here. Lorem ipsum dolor sit amet, 
        consectetur adipiscing elit. Aliquam consequat diam ut tortor 
        dignissim, vel accumsan libero venenatis. Nunc pretium volutpat 
        convallis. Integer at metus eget neque hendrerit vestibulum. 
        Aenean vel mattis purus. Fusce condimentum auctor tellus eget 
        ullamcorper. Vestibulum sagittis pharetra tellus mollis vestibulum. 
        Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
        <a class="close-button" popup-close="popup-1" href="javascript:void(0)">x</a>
            </div>
        </div>  
</body>
</html>

๐ŸŒ
CodePen
codepen.io โ€บ akb20 โ€บ pen โ€บ waymXJ
Animated jQuery Modal Pop-up
If disabled, use the "Run" button to update. If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting. ... Visit your global Editor Settings. ... <head> <!-- Ionicons--> <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> </head> <body> <!--Overlay & Modal--> <div class="overlay"> <div class="modal"> <div class="close-btn"><i class="ion-close"></i> </div> <div class="text-box"> <p class="lead">Be sure to subscribe to receive awesome content, lollipops, and free Happy Meals!</p> <p class="tagline">In Your Spam Folder...
๐ŸŒ
CodePen
codepen.io โ€บ tag โ€บ jquery-modal
Pens tagged 'jquery-modal' on CodePen
CodePen doesn't work very well without JavaScript ยท We're all for progressive enhancement, but CodePen is a bit unique in that it's all about writing and showing front end code, including JavaScript. It's required to use most of the features of CodePen ยท Need to know how to enable it?
๐ŸŒ
CodePen
codepen.io โ€บ rajrs โ€บ pen โ€บ NNjbpE
open bootstrap model onclick
<div id="testmodal" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <h4 class="modal-title">Confirmation</h4> </div> <div class="modal-body"> <p>Do you want to save changes you made to document before closing?</p> <p class="text-warning"><small>If you don't save, your changes will be lost.</small></p> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="button" class="btn b
๐ŸŒ
Zditect
zditect.com โ€บ blog โ€บ 2105770.html
Open modal popup using jQuery on button click CodePen,
A jQuery click event handler has been assigned to the Button. When the Button is clicked the jQuery UI Dialog Modal Popup is shown.
๐ŸŒ
CodePen
codepen.io โ€บ EdWise โ€บ pen โ€บ gOOvGgw
Modal Pop-up with YouTube iframe and jQuery
$(document).ready(function() { // Watch More Link click handlers const $popup = $('.video-popup'); const $modal = $('#modal'); const $closeIcon = $('.close'); const $watchMoreLink = $('.watch-more'); $watchMoreLink.click(function(e) { $popup.fadeIn(200); $modal.fadeIn(200); e.preventDefault(); }); $closeIcon.click(function () { $popup.fadeOut(200); $modal.fadeOut(200); }); // for escape key $(document).on('keyup',function(e) { if (e.key === "Escape") { $popup.fadeOut(200); $modal.fadeOut(200); } }); // click outside of the popup, close it $modal.on('click', function(e){ $popup.fadeOut(200); $modal.fadeOut(200); }); });