javascript - Lightbox like a popup -


this code lightbox, it's necessary click show content, , need appearing without click. automatic. kind pop up.

$(document).ready(function() {   $('.lightbox').click(function() {     $('.background, .box').animate({       'opacity': '.60'     }, 500, 'linear');     $('.box').animate({       'opacity': '1.00'     }, 500, 'linear');     $('.background, .box').css('display', 'block');   });    $('.close').click(function() {     $('.background, .box').animate({       'opacity': '0'     }, 500, 'linear', function() {       $('.background, .box').css('display', 'none');     });;   });    $('.background').click(function() {     $('.background, .box').animate({       'opacity': '0'     }, 500, 'linear', function() {       $('.background, .box').css('display', 'none');     });;   }); }); 

how's this? move code functions , run open popup function on document ready:

$(document).ready(function() {   $('.lightbox').click(function() {     openpopup();   });    $('.close').click(function() {     closepopup();   });    $('.background').click(function() {     closepopup();   });     openpopup(); });   function openpopup() {     $('.background, .box').animate({       'opacity': '.60'     }, 500, 'linear');     $('.box').animate({       'opacity': '1.00'     }, 500, 'linear');     $('.background, .box').css('display', 'block'); }  function closepopup() {     $('.background, .box').animate({       'opacity': '0'     }, 500, 'linear', function() {       $('.background, .box').css('display', 'none');     }); } 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -