hide jquery facebox modal manually

2019-08-20 09:29发布

问题:

I used my custom close button on my facebox modal to close it... It works fine (ie) it closes but it appends to the bottom of the page after i click the close button...

<a onclick="$.facebox.close();" href="javascript:void(0);" class="close"> 
  <img alt="Close the popup" src="images/close.png" title="close" 
     class="close_image" /> 
</a>

Here is what i get,

Here is what i am trying to do,

$(document).bind('close.facebox', function() {
        $(document).unbind('keydown.facebox')
        $('#aspnetForm').append($('#facebox .content').html());
        /// extra line to make sure there's no flashing effect as the facebox closes: the content is still in there too!
        $('#facebox .content').children().css({ 'display': 'block' });
        $('#facebox').fadeOut(function() {
            $('#facebox .content').removeClass().addClass('content')
            hideOverlay()
            $('#facebox .loading').remove()
        })

    })

My page has this,

   $(document).ready(function($) {
        $.facebox.settings.opacity = 0.2;
        $('a[rel*=facebox]').facebox();
     });

  <div id="forgetPassword" style="display:none"> 
    //content
   </div>

回答1:

I replaced OnClick to this onclick="javascript:$(document).trigger('close.facebox')" and it worked..



回答2:

could it be as easy as fixing your selector?:

<a onclick="$('#facebox').close();" href="javascript:void(0);" class="close">  
  <img alt="Close the popup" src="images/close.png" title="close"  
     class="close_image" />  
</a>