This jQuery snippet doesn’t seem to work with WordPress

the problem was in your variable define syntax and also you need to wrap your jQuery script into no conflict wrapper, try this

jQuery(window).load(function($) {
   // your function
});

or

(function($) {
  // your function
})(jQuery);

complete working script

(function($) {
   $(window).load(function() {
     var lightBox = $('#lightbox');
     var lightBoxContent = $('#lb-content');
     var positionLightbox = function() {
         var veiwWidth = $(window).width();
         var lbContentMargin = (veiwWidth / 2) - 148;
         var lbContent = $('#lb-content');
         lbContent.css({
           'left' : lbContentMargin,
           'top' : $(window).scrollTop() + 50 + 'px'
         });
     };

     $('.modal-trigger').click(function() {
         lightBox.fadeIn(function() {
         lightBoxContent.show();
     });
     positionLightbox();
     });
     $('#lb-close').click(function() {
         lightBox.hide();
         lightBoxContent.hide();
     });
   });
})(jQuery);

Leave a Comment