开发者

Problematic function call in Jquery

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开发者_Python百科_overlay"></div>').appendTo('body');
}

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

Any help will be greatly appreciated


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜