1 if (jQuery && !jQuery.fn.forEach) {
 2     $(function () {
 3         (function ($) {
 4             $.fn.extend({
 5                 forEach: function (predicate) {
 6 
 7                     if (this == null) {
 8                         throw new TypeError(' this is null or not defined');
 9                     }
10 
11                     // 1. Let O be the result of calling toObject() passing the
12                     // |this| value as the argument.
13                     var O = Object(this);
14 
15                     // 2. If isCallable(predicate) is false, throw a TypeError exception. 
16                     if (typeof predicate !== "function") {
17                         throw new TypeError(predicate + ' is not a function');
18                     }
19 
20                     //3 call the jq  original API  for iteror
21                     $.each(O, function (index, domEle) {
22                         predicate($(domEle));
23                     });
24                 }
25             })
26         })(jQuery);
27 
28     });
29 }

 

相关文章:

  • 2022-01-13
  • 2022-12-23
  • 2022-03-02
  • 2022-02-16
  • 2022-12-23
猜你喜欢
  • 2022-03-04
  • 2021-10-01
  • 2022-12-23
  • 2022-12-23
  • 2022-03-06
  • 2022-12-23
  • 2021-04-25
相关资源
相似解决方案