jquery live & livequery

陌路散爱 提交于 2019-12-11 03:36:11

问题


I'm using jquery's load to bring in thumbnails via ajax. I'd like to user to be able to hover over the cropped thumb to view a small uncropped version of the image using imgPreview plugin. If they click on it, then bring up the full sized image in a lightbox (fancybox).

For the lightbox, I have:

$("ul#plant_gallery li a").livequery( function(){   
    $(this).fancybox ({ 'overlayOpacity': 0.9, 'overlayColor': '#000', });
});

And for the tooltip uncropped image hover, I have:

$('ul#plant_gallery li a').live('mouseover', function()
{
    if (!$(this).data('init'))
    {
        $(this).data('init', true);
        $(this).imgPreview({imgCSS: { width: 200 }, srcAttr: 'rel'})
        (
            function()
            {

            },

            function()
            {
            }
        );
        $(this).trigger('mouseover');
    }
});

How can I combine these two into one? Should I be using either jquery's live or livequery? Thanks for your help!


回答1:


I think you don't NEED to combine them, have you tried:

$("ul#plant_gallery li a").live('click', function(){   
    $(this).fancybox ({ 'overlayOpacity': 0.9, 'overlayColor': '#000', });
});

And leaving the other function as it is?



来源:https://stackoverflow.com/questions/1878896/jquery-live-livequery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!