Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.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/4/macos/9.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 如何运行动画&x2B;一次回调函数_Jquery_Function_Callback - Fatal编程技术网

Jquery 如何运行动画&x2B;一次回调函数

Jquery 如何运行动画&x2B;一次回调函数,jquery,function,callback,Jquery,Function,Callback,我希望我的函数运行一次,因此h1元素将转到45px一次,然后使用回调函数(将不透明度更改为0.2)。同样的道理也适用于mouseout $("article.recensie").mouseover(function () { // vraag a $("article.recensie h1").animate({ fontSize: '45px' }, 500, function () { $("article.recensie").animate({

我希望我的函数运行一次,因此h1元素将转到45px一次,然后使用回调函数(将不透明度更改为0.2)。同样的道理也适用于mouseout

$("article.recensie").mouseover(function () { // vraag a

  $("article.recensie h1").animate({
    fontSize: '45px'
  }, 500,

  function () {
    $("article.recensie").animate({
        opacity: '0.2'
    }, 500);
  })
});

$("article.recensie").mouseout(function () {

  $("article.recensie h1").animate({
    fontSize: '40px'
  }, 250,

  function () {
    $("article.recensie").animate({
        opacity: '1'
    }, 500);
  })
});

如果您只想设置css属性的动画,我建议您使用CSS3而不是jQuery

此处的示例和说明:

此处的工作示例:


你能描述一下你当前的代码中哪些是有效的,哪些是无效的吗?整个代码都是有效的,但问题是,当我将鼠标悬停在上面一次时,它会继续执行动画,而不是执行一次。你的代码对我有效,请检查。
  article.recensie {
    background-color: red;
    opacity: 1;
    font-size: 40px;
    -webkit-transition: all 1s ease-in-out;
    -moz-transition: all 1s ease-in-out;
    -o-transition: all 1s ease-in-out;
    transition: all 1s ease-in-out;
  }

  article.recensie:hover {
    opacity: 0.2;
    font-size: 45px;
  }