Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a popup div. div is appearing on screen as expected with complete css. But its not closing, closing button is not working and click in the background is also not working, plz help

HTML Code:

More HTML Tutorials
Click me


<form>
<input type="text" name="random"/>


<button type="button" class="close" id="close">Click to close</button>

</form>



Javascript Code:
JavaScript
<pre lang="Javascript">

$(document).ready(function() {
$('a.popup-window').click(function(){

var popupBox=$(this).attr('href');
$(popupBox).fadeIn(400);


var popMargTop = ($(popupBox).height() +24)/2;
var popMargLeft = ($(popupBox).width() +24)/2;

$(popupBox).css({
'margin-top':-popMargTop,
'margin-left':-popMargLeft
});

$('body').append('
');
$('#mask').fadeIn(400);
return false;

});

$('button.close, #mask').live('click', function(){

$('#mask, .popupInfo').fadeOut(400, function(){
$('#mask').remove();

});
return false;
});
});
Posted
Updated 3-Jun-15 8:44am
v2
Comments
Sergey Alexandrovich Kryukov 29-Jan-15 14:59pm    
There is no such concept as "close an element". :-)
Why using .remove()? Do you mean that you will never use "#mask" element?
Why nut using .hide()?
—SA
vbmike 29-Jan-15 15:05pm    
Look into jquery toggle. http://api.jquery.com/toggle/. See if something like that may assist you.

1 solution

Chnage the code like below
C#
$('button.close, #mask').click(function(){

$('#mask, .popupInfo').fadeOut(400, function(){	
$('#mask').remove();

});

Hope this helps
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900