Nifty Modal - how to trigger a modal without a button

后端 未结 7 1831
有刺的猬
有刺的猬 2021-01-03 14:55

This script provides awesome modal transitions and I want to use them instead of a standard alert message.

Now the demo of the script shows how to trigger them by pr

相关标签:
7条回答
  • 2021-01-03 15:47

    I use the following code

    $(document).ready(function () {
            openpop();
        })
    
        function openpop(){
            var overlay = document.querySelector( '.md-overlay' );
    
            var modal = document.querySelector('#modal-11'),
                    close = modal.querySelector( '.md-close' );
    
            function removeModal( hasPerspective ) {
                classie.remove( modal, 'md-show' );
    
                if( hasPerspective ) {
                    classie.remove( document.documentElement, 'md-perspective' );
                }
            }
    
            function removeModalHandler() {
                removeModal( classie.has( modal, 'md-setperspective' ) ); 
            }
    
    
            classie.add( modal, 'md-show' );
                overlay.removeEventListener( 'click', removeModalHandler );
                overlay.addEventListener( 'click', removeModalHandler );
    
                if( classie.has( modal, 'md-setperspective' ) ) {
                    setTimeout( function() {
                        classie.add( document.documentElement, 'md-perspective' );
                    }, 25 );
                }
    
    
            close.addEventListener( 'click', function( ev ) {
                ev.stopPropagation();
                removeModalHandler();
            });
        }
    
    0 讨论(0)
提交回复
热议问题