Jquery JS-如何将此脚本设置为应用于多个类实例?

Jquery JS-如何将此脚本设置为应用于多个类实例?,jquery,multiple-instances,Jquery,Multiple Instances,我得到了下面的脚本,以便它将一个函数应用于具有class.cloudzoom的所有元素。它可以工作,但只适用于第一个元素。我知道每个()函数都有一些事情要做,但我对脚本编写还不太熟悉 有什么帮助吗/ 试试这个: (function($){ // When mouse leaves browser... $(document).bind('mouseleave',function(){ // Get the Cloud Zoom i

我得到了下面的脚本,以便它将一个函数应用于具有class.cloudzoom的所有元素。它可以工作,但只适用于第一个元素。我知道每个()函数都有一些事情要做,但我对脚本编写还不太熟悉

有什么帮助吗/

试试这个:

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

耶!这个有效!:)谢谢你的时间和努力!以上两个都回答了!哎呀。我忘了有一个括号。很抱歉
     (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);
   (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);