1

This works:

$("a.lightbox").click(function (e) {
    //var heading = $(this).attr('rel')
    // hide scrollbars!
    $('body').css('overflow-y', 'hidden')
    $('body').css('overflow-x', 'hidden');
    $('<div id="lightbox_overlay"></div>').appendTo('body');    
    return false;
});

But this doesn't

function showImage(){
    $('body').css('overflow-y', 'hidden')
    $('body').css('overflow-x', 'hidden');
    $('<div id="lightbox_overlay"></div>').appendTo('body');
}

$("a.lightbox").click(function (e) {
    showImage();
    return false;
});

Any help will be greatly appreciated

1 Answer 1

1

Does this work?

(function($) {

    function showImage() {

        $("body").css({

            "overflow-y" : "hidden",
            "overflow-x" : "hidden" 

        });

        $('<div id="lightbox_overlay"></div>').appendTo("body");

    }

    $("a.lightbox").click(function(e) {

        e.preventDefault();
        showImage();

    });

})(jQuery);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.