2013-08-30 42 views
2

我有以下js插件捕捉元素的show hide事件。但我想只针对One dom元素,即#div_loading_page使插件元素特定

jQuery(function ($) { 
    $.each(['show','hide'], function (i, ev) { 
     var el = $.fn[ev]; 
     $.fn[ev] = function() { 
       this.trigger(ev); 
       el.apply(this, arguments); 

     }; 
    }); 
}); 

任何人都可以请帮忙。谢谢

+1

比较你的ID插件,如果它是一个(div_loading_page)让函数运行..否则返回false。 – maverickosama92

回答

1
jQuery(function ($) { 
    $.each(['show','hide'], function (i, ev) { 
     var el = $.fn[ev]; 
     $.fn[ev] = function() { 

      this.each(function() { 
       if (this.id == 'div_loading_page') { 
        $(this).trigger(ev); 
        return false; // break out of the loop 
       } 
      }); 

      el.apply(this, arguments); 
     }; 
    }); 
}); 
+0

谢谢但它没有多大帮助,我不得不删除隐藏事件,并在点击关闭按钮时添加逻辑。 – Eez