jqueryfancybox

jQUery fancybox launch onclick


Here is the Javascript:

$(document).ready(
   function(){
        $('#button').click(function() {
        $("#content_of_fancybox").fancybox({
            'scrolling'     : 'no',
            'titleShow'     : false
        });
        });
   }
);

And the HTML

<input type="button" value=" Open fancybox " id="button">

<div id="content_of_fancybox" style="width: 400px; margin: 0; display: none;">
Hello pandas!
</div>

The fancybox should open when the user clicks on the button, but it doesn't. What is the error (I guess it's in the javascript part)?


Solution

  • Fancybox works on click of the object that you attach the fancybox to: http://jsfiddle.net/maniator/WbCMV/2/


    If you want a dialog just use jQuery dialog:

    http://jsfiddle.net/maniator/WbCMV/4/