首页 > 解决方案 > jQuery 3.2.1 与旧脚本不兼容

问题描述

我有这个旧代码现在不能与新的 jQuery 库一起使用。它适用于 1.7.2,但我现在使用的是 3.2.1。代码中是否有任何更改,以便它可以与新库一起使用?

<div class="last-screem-open" id="last-screem-open" onclick="$('#last-screem-open,#last-screem-text,#last-screem-open-button').animate({left: '-=60'}, 200, 'linear');$('#last-screem-wrapped').delay(300).animate({left: '+=250'}, 200, 'linear');">
  <b class="last-screem-open-button" id="last-screem-open-button">▸&lt;/b><span id="last-screem-text">TExt</span>
</div>
(function($) {
  $('.macro-post-poster img, .post-block-poster img').show().lazyload({
    effect: 'fadeIn',
    threshold: 200
  });

  $("img.lazy").lazyload({
    container: $("#right")
  });
})(jQuery);

标签: javascriptjquery

解决方案


您可以使用Jquery migrate ,在您的工作jquery 库 (1.7.x)之后添加它,它将突出显示您需要更改的内容以使您的代码在版本 3.x 中工作。

只需检查控制台的输出即可。


推荐阅读