Javascript-参数列表后的Fadein效果Uncaught SyntaxError:缺少) [英] Javascript - fadein effect Uncaught SyntaxError: missing ) after argument list

查看:130
本文介绍了Javascript-参数列表后的Fadein效果Uncaught SyntaxError:缺少)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将一个前端站点加载到Wordpress上,并且在使用jQuery函数的$进行编辑之前,该JavaScript文件可以正常工作,以避免出现任何冲突. 现在,我在控制台中收到上面的错误,似乎无法纠正. 我在此处记录的问题上无法在Safari上实现此效果.

I'm loading a front-end site onto Wordpress and a javascript file that was working fine before has been edited to avoid any conflicts using $ for jQuery functions. Now I'm getting the error above in the console and can't seem to rectify. I've been having issues with making this effect work on Safari as documented here .

这是我在javascript文件中的代码-

Here's my code in the javascript file -

fadein.js

$.noConflict();

jQuery(document).ready(function($) {
  var win = $(window),
    doc = $(document),
    tags = $("section");

  win.on("scroll", function() {
      tags.each(function(i, tag) {
        if ($(tag).position().top < (doc.scrollTop() + win.outerHeight())) {
          $(tag).addClass("visible");
        } else {
          $(tag).removeClass("visible");
        }
      });
    }
  });
});

以及部分不透明度的css-

And the css for the section opacity -

style.css

/* Fade in/out */


section {
  opacity: 0;
  -webkit-transform: translate(0, 10px); 
  -webkit-transition: all 1s;
  transform: translate(0, 10px); 
  transition: all 1s;
}

section.visible { 
  opacity: 1;
  -webkit-transform: translate(0, 0); 
  transform: translate(0, 0); 
}


/*  ---------------------- */

由于此错误,我无法确定已编辑的代码是否能在Safari上运行.在Chrome和Firefox上运行正常.任何帮助表示赞赏.

I'm unable to tell if the edited code works on Safari as yet because of this error. It was working fine on Chrome and Firefox. Any help appreciated.

更新-

控制台错误读取-

推荐答案

在这里使用正确的语法

$.noConflict();

jQuery(document).ready(function($) {
  var win = $(window),
    doc = $(document),
    tags = $("section");

  win.on("scroll", function() {
    tags.each(function(i, tag) {
      if ($(tag).position().top < (doc.scrollTop() + win.outerHeight())) {
        $(tag).addClass("visible");
      } else {
        $(tag).removeClass("visible");
      }
    });
  });
});

希望这会对您有所帮助.

Hope this will help you.

这篇关于Javascript-参数列表后的Fadein效果Uncaught SyntaxError:缺少)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆