Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用jquery检查css的底部_Jquery_Html_Css - Fatal编程技术网

使用jquery检查css的底部

使用jquery检查css的底部,jquery,html,css,Jquery,Html,Css,我正在尝试用引号做一种提要,如果它在屏幕上下降到某个级别以下,我想重置一个引号 function MoveDown(speed) { $('#QuoteOne').animate({ bottom: '-=100' }, speed); $('#QuoteTwo').animate({ bottom: '-=100'

我正在尝试用引号做一种提要,如果它在屏幕上下降到某个级别以下,我想重置一个引号

function MoveDown(speed) {

            $('#QuoteOne').animate({
                  bottom: '-=100'
                }, speed);

            $('#QuoteTwo').animate({
                  bottom: '-=100'
                }, speed);

            $('#QuoteThree').animate({
                  bottom: '-=100'
                }, speed);

            $('#QuoteFour').animate({
                  bottom: '-=100'
                }, speed);

            console.log($('#QuoteOne').css("bottom"));  

            if($('#QuoteOne').css("bottom") == '-400px' )
            {   
                $('#QuoteOne').animate({
                  bottom: '= 0'
                }, speed);
            }
        }

控制台日志显示为-400px,但我无法将其移回顶部。我缺少什么?

首先,该代码将在动画完成之前执行。如果希望在动画之后执行该代码,请将其作为回调添加到
”QuoteOne
元素的
animate
函数中:

$('#QuoteOne').animate({
  bottom: '-=100'
}, speed, function() {
  if ( $(this).css("bottom") == "-400px" )
    ...
});
然后将
bottom:'=0'
更改为
bottom:0

$('#QuoteOne').animate({
  bottom: 0
}, speed);

那正是它的本来面目。你能告诉我为什么“-=”有效而“=”无效吗?@PatrickSchomburg我无法回答这个问题。这可能是因为jQuery不只是处理
=n
,而
+=
-=
在JavaScript中是有效的数学运算符。我很难链接它们。我需要三个报价块一起向下移动,然后最底部的一个在顶部淡入。您的代码修复了这一点,但仅针对一个引号div。@PatrickSchomburg您可以将选择器与逗号组合:
$(''QuoteOne,'quotewo,…')。动画(…)