//

作者:lofayo    发布于:

  // 封装jQuery两个类名的切换(注意:this的指代)
  (function($) {
    $.fn.toggle = function(a, b) {
      if (arguments.length == 1) {
        $(this).toggleClass(arguments[0]);
      } else {
        return $(this).hasClass(a) ? $(this).removeClass(a).addClass(b) : $(this).removeClass(b).addClass(a);
      }
    }
  })(jQuery)

等待封装的插件

  function youPlay() {
    var winH = $(window).height();
    $("video").each(function() {
      var posTop = $(this).offset().top;
      var scrollH = $(window).scrollTop(); //浏览器滚动高度
      var targetH = $(this).height();
      var needShow = (posTop - winH + winH / 2) <= scrollH && scrollH <= (posTop - winH + winH / 2 + targetH);
      if (needShow) {
        $('video').each(function() {
          $(this)[0].pause();
        })
        $(this)[0].play();
      }
    })
  }
format_list_numbered

(无)

vertical_align_top

Copyright © 2017 每天寻求一点变化

Powered by Hexo & Theme - Vateral