Hey guys, girls,
Here I’m going to teach you too simple lightbox popup window to see it before.
Add these lines into your body tag whenever you want. If may be you can arrange it according to your requirement. But make sure to be having position:fixed; and z-index:100 or 100+;
And then add these JavaScript code to yor head tag
- function hidePopUp(){
- $('#divPopUp').html('');
- $('#divPopUp').hide();
- }
- $(document).ready(function(){
- $('#divPopUp').hide();
- $('.small_image').click(function(){
- $('#divPopUp').html('</p><div align="center">---------------Here Add Your Tag/Content whatever you want---------------<br/><span onclick="hidePopUp()" style="cursor: pointer">CLOSE</span></div>');
- $('#divPopUp').show();
- });
- });
Here is a complete example of code which I have used it for image gallery section:
- <html>
- <head>
- <script>
- function hidePopUp(){
- $('#divPopUp').html('');
- $('#divPopUp').hide();
- }
- $(document).ready(function(){
- $('#divPopUp').hide();
- $('.small_image').click(function(){
- var largeImageSrc=$(this).attr('src');
- largeImageSrc=largeImageSrc.replace('small','big');
- $('#divPopUp').html('<div align="center"><img src="'+largeImageSrc+'"/><br/><span onclick="hidePopUp()" id="btnClose" style="cursor: pointer">CLOSE</span></div>');
- $('#divPopUp').show();
- });
- });
- </script>
- </head>
- <body>
- <?php
- echo '<ul class="gallerylist">';
- {
- echo '<li><div align="center" style="">'.$row['image_name'].'</div><img class="small_image" style="cursor:pointer;" src="admin/gallery_image/small/'.$row['image_id'].'.'.$row['image_ext'].'"/></li>';
- }
- echo '</ul>';
- ?>
- <div id="divPopUp" style="border: solid 3px #408080;position: fixed;top: 5%;left: 20%;width: 60%;height: 70%;background: #002200;color: #d9e3e8;z-index: 101;"></div>
- </body>
- </html>
See the Pen Light Box by AHMAD ASJAD (@ahmadasjad) on CodePen.0
Happy coding!!!!!!!