jQuery not closing my popup on click
Hi All
I am testing a Popup window using jQuery but I am not able close it. Can any one help me in closing this popup.
This my HTML Code
- <script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
- <script>
- $(document).ready(function() {
- //Put in the DIV id you want to display
- launchWindow('#dialog1');
- //if close button is clicked
- $('.window #close').click(function () {
- $('#mask').hide();
- $('.window').hide();
- });
- //if mask is clicked
- $('#mask').click(function () {
- $(this).hide();
- $('.window').hide();
- });
- $(window).resize(function () {
- var box = $('#boxes .window');
- //Get the screen height and width
- var maskHeight = $(document).height();
- var maskWidth = $(window).width();
- //Set height and width to mask to fill up the whole screen
- $('#mask').css({'width':maskWidth,'height':maskHeight});
- //Get the window height and width
- var winH = $(window).height();
- var winW = $(window).width();
- //Set the popup window to center
- box.css('top', winH/2 - box.height()/2);
- box.css('left', winW/2 - box.width()/2);
- });
- });
- function launchWindow(id) {
- //Get the screen height and width
- var maskHeight = $(document).height();
- var maskWidth = $(window).width();
- //Set heigth and width to mask to fill up the whole screen
- $('#mask').css({'width':maskWidth,'height':maskHeight});
- //transition effect
- $('#mask').fadeIn(1000);
- $('#mask').fadeTo("slow",0.8);
- //Get the window height and width
- var winH = $(window).height();
- var winW = $(window).width();
- //Set the popup window to center
- $(id).css('top', winH/2-$(id).height());
- $(id).css('left', winW/2-$(id).width()/2);
- //transition effect
- $(id).fadeIn(2000);
- }
- </script>
- </head>
- <body>
- <!-- Start of Login Dialog -->
- <div id="boxes">
- <div id="dialog1" class="window">
- <div class="d-header">
- <div style="padding-top:50px;padding-left:115px;">
- <img src="jquery-modal-window-queness/images/dapl-representative-small.jpg" width="151" height="100" />
- </div>
- <input type="text" value="Enter Phone No." onclick="this.value=''"/><br/>
- <input type="text" value="Enter eMail ID" onclick="this.value=''"/> <br /><br />
- <font color="#FF9F38">Please give us your details and our representative will contact with you.</font>
- </div>
- <input type="image" alt="Close" title="Close" src="jquery-modal-window-queness/images/x.png" class="close"/>
- </div>
- </div>
- <div id="mask"></div>
- <!-- End of Login Dialog -->
Now When I click on on the masked area Pop disappear but when I click on the image x.png Popup doesn't go away.
I need some hint or guidance.
Thank you all.