Home / Tips / Programming languages / Scripting languages / JavaScript / How to open jQuery Fancybox automatically with content from div element

How to open jQuery Fancybox automatically with content from div element

jQuery
 
jQuery
  • Currently 0 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Rating: 0/5 (0 votes cast)

Thank you for rating!

You have already rated this page, you can only rate it once!

Your rating has been changed, thanks for rating!

Log in or create a user account to rate this page.


It can be simply done by using advanced option content for jQuery Fancybox.

Any HTML data can be passed to the option content.

The following code uses function html in jQuery to get HTML content of div element with id "lightbox-content" and passes it to the option content.

jQuery.fancybox({
  content: jQuery( '#lightbox-content' ).html()
});

 

Read also

jQuery for beginners: selectors

jQuery for beginners: selectors

jQuery for beginners: AJAX

jQuery for beginners: AJAX

jQuery for JavaScript

jQuery for JavaScript

jQuery UI. Widgets. Dialog (Windows)

jQuery UI. Widgets. Dialog (Windows)

Post comment

basicuse.net
html5_css
106160485398655174790

Quick navigation

General navigation