简体   繁体   English

在JQuery中滚动到时,元素会向下滑动

[英]Have element slidedown when scrolled to in JQuery

I'd like to have an opacity:0 element slide down when it is in the viewport. 我想让opacity:0元素在视口中向下滑动。 I'm currently able to have it fade in when it is scrolled to, because the prerequisite for the jquery code to work is to have the opacity as 0. https://jsfiddle.net/agreyfield91/5c0raLp9/ 我目前能够在滚动到它时使其淡入,因为jQuery代码起作用的前提是不透明度为0。https ://jsfiddle.net/agreyfield91/5c0raLp9/

In my jfiddle, I'm trying to do this: 在我的jfiddle中,我正在尝试执行以下操作:

$("#SlideDownOnScroll").css(
            "opacity": "1";
            "display":"none").slideDown("fast");

In order to first convert the display aspect needed to slideDown, but it isn't working. 为了首先将显示方面转换为slideDown,但它不起作用。 Is there a better way to achieve what I'm doing, or a way to fix it? 有没有更好的方法可以实现我正在做的事情,或者可以解决该问题?

It looks like the css argument has incorrect syntax: 看起来css参数的语法不正确:

$("#SlideDownOnScroll").css({
        "opacity": "1",
        "display":"none"
  }).slideDown("fast");

In the fiddle you linked the jQuery selector is missing the # in the selector. 在链接的小提琴中,jQuery选择器缺少选择器中的# $("#SlideDownOnScroll")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM