Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7520513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:05:03+00:00 2026-05-30T02:05:03+00:00

This is my first plugin trying to create using the example provided here .

  • 0

This is my first plugin trying to create using the example provided here.

Now in the example there is a link where we can close the lightbox by clicking it.
But I want to know how do I Close it on clicking the background(ie..Anywhere on the webpage)

This is what I have tried but it did not work.

 $('.paulund_block_page').click(function(){
          $(pop_up).fadeOut().remove();
 });

Can anyone say me where I went wrong?

Edit:This is the full plugin:

    (function($){

    // Defining our jQuery plugin

    $.fn.paulund_modal_box = function(prop){

        // Default parameters

        var options = $.extend({
            height : "250",
            width : "500",
            title:"JQuery Modal Box Demo",
            description: "Example of how to create a modal box.",
            top: "20%",
            left: "30%",
        },prop);

        return this.click(function(e){
            add_block_page();
            add_popup_box();
            add_styles();

            $('.paulund_modal_box').fadeIn();
        });

         function add_styles(){
            $('.paulund_modal_box').css({
                'position':'absolute',
                'left':options.left,
                'top':options.top,
                'display':'none',
                'height': options.height + 'px',
                'width': options.width + 'px',
                'border':'1px solid #fff',
                'box-shadow': '0px 2px 7px #292929',
                '-moz-box-shadow': '0px 2px 7px #292929',
                '-webkit-box-shadow': '0px 2px 7px #292929',
                'border-radius':'10px',
                '-moz-border-radius':'10px',
                '-webkit-border-radius':'10px',
                'background': '#f2f2f2',
                'z-index':'50',
            });
            $('.paulund_modal_close').css({
                'position':'relative',
                'top':'-25px',
                'left':'20px',
                'float':'right',
                'display':'block',
                'height':'50px',
                'width':'50px',
                'background': 'url(images/close.png) no-repeat',
            });
                        /*Block page overlay*/
            var pageHeight = $(document).height();
            var pageWidth = $(window).width();

            $('.paulund_block_page').css({
                'position':'absolute',
                'top':'0',
                'left':'0',
                'background-color':'rgba(0,0,0,0.6)',
                'height':pageHeight,
                'width':pageWidth,
                'z-index':'10'
            });
            $('.paulund_inner_modal_box').css({
                'background-color':'#fff',
                'height':(options.height - 50) + 'px',
                'width':(options.width - 50) + 'px',
                'padding':'10px',
                'margin':'15px',
                'border-radius':'10px',
                '-moz-border-radius':'10px',
                '-webkit-border-radius':'10px'
            });
        }

         function add_block_page(){
            var block_page = $('<div class="paulund_block_page"></div>');

            $(block_page).appendTo('body');
        }

         function add_popup_box(){
             var pop_up = $('<div class="paulund_modal_box"><a href="#" class="paulund_modal_close"></a><div class="paulund_inner_modal_box"><h2>' + options.title + '</h2><p>' + options.description + '</p></div></div>');
             $(pop_up).appendTo('.paulund_block_page');

             $('.paulund_modal_close').click(function(){
                $(this).parent().fadeOut().remove();
                $('.paulund_block_page').fadeOut().remove();
             });
        }

        return this;
     };
 $('.paulund_block_page').click(function(){
       $(pop_up).fadeOut(function(){$(this).remove();});
       $('.paulund_block_page').fadeOut(function(){$(this).remove();});
});
})(jQuery);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T02:05:05+00:00Added an answer on May 30, 2026 at 2:05 am

    There’s a typo in that plugin that keeps it from working for me.

    One of the lines says

    'height':pageheight
    

    when it should say

    'height':pageHeight
    

    (capitalize that h)

    If you then insert your code into the bottom of the add_popup_box function it works fine. However, the fade out doesn’t complete (it just disappears). Also, you forgot the code to remove the block page when you click the background.

    Try this:

    $('.paulund_block_page').click(function(){
        $(pop_up).fadeOut(function(){$(this).remove();});
        $('.paulund_block_page').fadeOut(function(){$(this).remove();});
    });
    

    That will wait until the fade animation is complete before it removes the modal box and block page.

    Update: You were adding the code to the wrong place. Here’s what the plugin should look like:

    (function($){
    
        // Defining our jQuery plugin
    
        $.fn.paulund_modal_box = function(prop){
    
            // Default parameters
    
            var options = $.extend({
                height : "250",
                width : "500",
                title:"JQuery Modal Box Demo",
                description: "Example of how to create a modal box.",
                top: "20%",
                left: "30%",
            },prop);
    
            return this.click(function(e){
                add_block_page();
                add_popup_box();
                add_styles();
    
                $('.paulund_modal_box').fadeIn();
            });
    
             function add_styles(){
                $('.paulund_modal_box').css({
                    'position':'absolute',
                    'left':options.left,
                    'top':options.top,
                    'display':'none',
                    'height': options.height + 'px',
                    'width': options.width + 'px',
                    'border':'1px solid #fff',
                    'box-shadow': '0px 2px 7px #292929',
                    '-moz-box-shadow': '0px 2px 7px #292929',
                    '-webkit-box-shadow': '0px 2px 7px #292929',
                    'border-radius':'10px',
                    '-moz-border-radius':'10px',
                    '-webkit-border-radius':'10px',
                    'background': '#f2f2f2',
                    'z-index':'50',
                });
                $('.paulund_modal_close').css({
                    'position':'relative',
                    'top':'-25px',
                    'left':'20px',
                    'float':'right',
                    'display':'block',
                    'height':'50px',
                    'width':'50px',
                    'background': 'url(images/close.png) no-repeat',
                });
                            /*Block page overlay*/
                var pageHeight = $(document).height();
                var pageWidth = $(window).width();
    
                $('.paulund_block_page').css({
                    'position':'absolute',
                    'top':'0',
                    'left':'0',
                    'background-color':'rgba(0,0,0,0.6)',
                    'height':pageHeight,
                    'width':pageWidth,
                    'z-index':'10'
                });
                $('.paulund_inner_modal_box').css({
                    'background-color':'#fff',
                    'height':(options.height - 50) + 'px',
                    'width':(options.width - 50) + 'px',
                    'padding':'10px',
                    'margin':'15px',
                    'border-radius':'10px',
                    '-moz-border-radius':'10px',
                    '-webkit-border-radius':'10px'
                });
            }
    
             function add_block_page(){
                var block_page = $('<div class="paulund_block_page"></div>');
    
                $(block_page).appendTo('body');
            }
    
             function add_popup_box(){
                 var pop_up = $('<div class="paulund_modal_box"><a href="#" class="paulund_modal_close"></a><div class="paulund_inner_modal_box"><h2>' + options.title + '</h2><p>' + options.description + '</p></div></div>');
                 $(pop_up).appendTo('.paulund_block_page');
    
                 $('.paulund_modal_close').click(function(){
                    $(this).parent().fadeOut(function(){$(this).remove();});
                    $('.paulund_block_page').fadeOut(function(){$(this).remove();});
                 });
    
                 $('.paulund_block_page').click(function(){
                     $(pop_up).fadeOut(function(){$(this).remove();});
                     $('.paulund_block_page').fadeOut(function(){$(this).remove();});
                 });
            }
    
            return this;
         };
    })(jQuery);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first stab at trying to create a JQuery plugin, so I
First as a note I am using this plugin in a Rails app. Ok
i'm trying to create my first jQuery plugin. i got a prototype function called
I am trying to create my first WordPress plugin. Even in trying to create
I'm writing my first wordpress plugin and I'm trying to create a function to
I'm trying to create a map using gmap3.net plugin with Jquery, the script should
I'm trying to create my first Rails plugin and am having some troubles leveraging
This may be a very mundane question, but this is the first jQuery plugin
Using Dozer to map two objects, I have: /** /* This first class uses
#include <iostream> using namespace std; // This first class contains a vector and a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.