0

我得到了以下脚本,以便它将一个函数应用于所有具有类 .cloudzoom 的元素。它有效,但仅适用于第一个元素。我看到 each() 函数有一些事情要做,但我对脚本编写还不是很熟悉。

         (function($){
            // When mouse leaves browser...
            $(document).bind('mouseleave',function(){
                // Get the Cloud Zoom instance and close zoom window.
                var cz = $('.cloudzoom').data('CloudZoom');
                cz.closeZoom();
            });
        })(jQuery);

有什么帮助吗?:/

4

2 回答 2

0

试试这个:

     (function($){
        // When mouse leaves browser...
        $(document).bind('mouseleave',function(){
            // Get the Cloud Zoom instances and close their zoom windows.
            $('.cloudzoom').each(function() {
                $(this).data('CloudZoom').closeZoom();
            })
        });
    })(jQuery);
于 2013-04-09T09:43:42.517 回答
0
   (function($){
        // When mouse leaves browser...
        $(document).bind('mouseleave',function(){
            // Get the Cloud Zoom instance and close zoom window.
            $('.cloudzoom').each(function(){
               $(this).data('CloudZoom').closeZoom();
            });
        });
    })(jQuery);
于 2013-04-09T09:44:18.833 回答