Website Knowledge

HTML, CSS, Javascript, jQuery and more

Show DIV with jQuery Fancybox on Page Load

If you ever have to show some content e.g. a div with fancybox pop up on page load, its pretty simple. Add your content to a div and then hide it with css using display:none. As described in this post, if you have fancybox version 1.3.4, add the following code

Add the following code and you should see the fancybox popup with the hidden div as its content.

$(document).ready(function(){ var popup= $('#popup').css('display','block'); $.fancybox({content:popup}); })

Add comment

biuquote
  • Comment
  • Preview
Loading